I am using ASP.net with C# and I would like to have a list that i can code dynamically to look like somewhat this:
- Menu Item A
- Sub Menu Link 1
- Sub Menu Link 2
- Sub Menu Link 3
so far i have managed to create the first past by doing this:
BulletedList MainUl = new BulletedList();
MainUl.DisplayMode = BulletedListDisplayMode.HyperLink;
ListItem item = new ListItem("Menu Item A", "http://www.google.com");
MainUl.Items.Add(item);
panel.Controls.Add(MainUl);
The problem is i do not know how to nest the other sub items under the main "Menu Item A"
Any help is greatly appreciated :)
try with this code
Or this code
Use Tree view
Output:
Alternatively you can use
DataControl
( DataList, Repeater, GridView) withBulletedList
. You should try Menu or TreeView control.