Object Reference Not Set To An Instance of an Object

S

Stelios Skiathitis

I have an asp:table inside an itemtemplate of a datalist (dlstForDetails)
the id in three rows of the table is, tblrMembers1, tblrServices1,
tblrBelongs1

Depending on the "go" value of the querystring I want to show or hide any of
these rows.
The code is the following but I get the error

Object Reference not set to an instance of an object

Dim tblrMembers, tblrServices, tblrBelongs As TableRow

tblrMembers = CType(dlstForDetails.FindControl("tblrMembers1"), TableRow)
tblrServices = CType(dlstForDetails.FindControl("tblrServices1"), TableRow)
tblrBelongs = CType(dlstForDetails.FindControl("tblrBelongs1"), TableRow)

Select Case Request.QueryString("go")
Case "YP"
tblrMembers.Visible = False
tblrServices.Visible = False
tblrBelongs.Visible = False
Case "EP"
tblrMembers.Visible = False
Case "AN"
tblrServices.Visible = False
tblrBelongs.Visible = False
Case "KE"
tblrMembers.Visible = False
tblrBelongs.Visible = False
End Select
 
J

Josh

there are many possible causes.

the datalist will create a Header even if it does not show it. Check the
ItemType of the item before trying to hide anything as you table wont be in
the header
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top