SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2005
    Posts
    147
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    DataList Within LoginView

    I've a datalist within the logged in template. On the page_load first I'm ensuring the visitor is logged in

    Code:
    If User.Identity.IsAuthenticated Then
    Following that I'm just trying to populate the datalist...

    Code:
            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
                myDataAdapter.Fill(ds)
    
            Dim DataList1 As DataList = LoginView1.FindControl("DataList1")
                DataList1.DataSource = ds
                DataList1.DataBind()
                conConnect.Close()
    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.
    Turn My Text - íspuǝıɹɟ ʞooqǝɔɐɟ ɹnoʎ ǝzɐɯɐ puɐ ǝsnɟuoɔ

    Computer Game Cheats & Codes

  2. #2
    SitePoint Zealot
    Join Date
    Apr 2005
    Posts
    147
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found issue - Datalist was within another container and so I had to reference the container first.
    Turn My Text - íspuǝıɹɟ ʞooqǝɔɐɟ ɹnoʎ ǝzɐɯɐ puɐ ǝsnɟuoɔ

    Computer Game Cheats & Codes


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •