setting SelectedIndex of DataList nested inside of DataList?

Discussion in 'ASP .Net' started by Les Caudle, May 2, 2006.

  1. Les Caudle

    Les Caudle Guest

    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"
    ((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?
    Les Caudle, May 2, 2006
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.