I've a datalist within the logged in template. On the page_load first I'm ensuring the visitor is logged in
If User.Identity.IsAuthenticated Then
Following that I'm just trying to populate the datalist...
Dim myDataAdapter As SqlDataAdapter
Dim strToday As String = DateTime.Today.ToString("dd MMM yyyy")
conConnect = New SqlConnection(connstring)
myDataAdapter= New SqlDataAdapter("SELECT command goes here FROM my table", conConnect)
Dim ds As Data.DataSet = New Data.DataSet
Dim DataList1 As DataList = LoginView1.FindControl("DataList1")
DataList1.DataSource = ds
However this doesn't work, I get the following error:
Object reference not set to an instance of an object.
... Highlighting: DataList1.DataSource = ds
If I take the loginview away then it works, but I thought the loginview1.findcontrol part would solve any problems.
I would appreciate any help.