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:Repeater ID="repeater" EnableViewState="False" runat="server" OnItemDataBound="myItemDataBound">
 <HeaderTemplate>
   <ul>
    </HeaderTemplate>
     <ItemTemplate>
      <li><%# Eval("nome") %>
        <asp:BulletedList ID="bulletedList" runat="server"></asp:BulletedList>
      </li>
     </ItemTemplate>
     <FooterTemplate>
      </ul>
     </FooterTemplate>
</asp:Repeater>

And populate the bulletedList in ItemDataBound event:

protected void myItemDataBound(object sender, RepeaterItemEventArgs e)
{
    DataRowView row = e.Item.DataItem as DataRowView;
    if (null == row)
        return;

    DataSet1.table1Row currentRow = row.Row as DataSet1.table1Row ;

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

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

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