Skip to content Skip to sidebar Skip to footer

How To Add Second Level Bulleted List In Asp.net

I have the following HTML code which I am trying to convert to ASP.net control:

Solution 1:

How you can read from BulletedList Web Server Control, the BulletedList control can display list items as any of the following:

  • Static text The text displayed by the control is not interactive.
  • T:System.Web.UI.WebControls.HyperLink controls Users can click links to navigate to another page. You must provide a target URL as the Value property of individual items.
  • LinkButton controls Users can click individual items and the control performs a postback.

Anyway you can easily achieve your task, using instead a common repeater:

<asp:RepeaterID="repeater"EnableViewState="False"runat="server"OnItemDataBound="myItemDataBound"><HeaderTemplate><ul></HeaderTemplate><ItemTemplate><li><%# Eval("nome") %>
        <asp:BulletedListID="bulletedList"runat="server"></asp:BulletedList></li></ItemTemplate><FooterTemplate></ul></FooterTemplate></asp:Repeater>

And populate the bulletedList in ItemDataBound event:

protectedvoidmyItemDataBound(object sender, RepeaterItemEventArgs e)
{
    DataRowView row = e.Item.DataItemasDataRowView;
    if (null == row)
        return;

    DataSet1.table1Row currentRow = row.RowasDataSet1.table1Row ;

    if (currentRow != null)
    {
        BulletedList bList = e.Item.FindControl("bulletedList") asBulletedList;

        bList.Items.Add("Foo");
    }
}

Post a Comment for "How To Add Second Level Bulleted List In Asp.net"