Collapsible Nested Datalists ? Findcontrol by Value?

J

jobs

I have two Nested repeating Datalists with different data sources.

Currently the second Datalist is set to visible=false

I have an oncommand button on the first, that when selected I would
like to make it's sub datalist visible.

I'm a bit confused about how to refrence the instance of the second
datalist.

Below is the command from the first .

The Master Datalist is called datalista, the Sub is called Datalist1.

Sub View(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.CommandEventArgs)

CType(Datalist1.FindControl("Datalist1")), DataList).Visible =
True

End Sub

The above code is giving an error that I'm "not set to an instance of
an object"

e.CommandArgument conntains a value which could be used to identify
items inside Datalist1, I'm just wondering, how do I identify the
control itself it it no databound identifiers? and can I even have
specific instances as visible = true ???
 
D

David Wier

I have only tried it with GridViews and DataGrids -- but, you must find and
define it first - then, set it's properties. I haven't tried this, but it
should at least get you going the correct direction.
It should be more like:
Dim sList as DataList
sList = CType(MainDL.FindControl("Datalist1")), DataList)
sList.Visible = True

The other thing to look at is 'where' you're trying this - -
are you saying you have a button, that will be clicked to make the one in
that row visible?

David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top