setting SelectedIndex of DataList nested inside of DataList?

L

Les Caudle

I have a menu system composed of a DataList nested inside a DataList.

The outer DataList has it's DataSource (composed of a DataSet with two tables
linked by a CategoryPagesRelation Relation) set in the Page_Load.

The inner DataList has its DataSource set in the ascx file as:

<asp:DataList ID="PageList" runat="server" CellPadding="3" CellSpacing="0"
DataSource='<%#
((DataRowView)Container.DataItem).Row.GetChildRows("CategoryPagesRelation") %>'

The inner DataList is inside the SelectedItemTemplate of the outer DataList.

The inner DataList sub-menu displays inside the outer DataList, but there is a
problem with selecting an item inside the inner DataList.

Inside the PageLoad, the outer DataList has its SelectedIndex set before its
DataSource is set and DataBind is called.

This works, however - inner DataList's SelectedIndex cannot be set after the
outer DataList's DataBind as it will not be visible - and it cannot be set
before it as the object doesn't yet exist.

My guess is that the inner DataList's SelectedIndex must be set inside an
ItemDataBound of the outer DataList - but I'm not sure how to do this.

Any ideas on how to get this to work?
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top