Click here to Skip to main content
15,913,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using asp.net menu control.

i am not able to add more than 1 child menu item to parent item. i am able to get
from database but can't able display in parent menu.

i am using for loop code
Posted
Comments
Wendelius 19-May-12 6:12am    
Please post the code you have done so far.

1 solution

C#
foreach (DataRow parentItem in ds.Tables["Categories"].Rows)
  {
    MenuItem categoryItem = new MenuItem((string)parentItem["CategoryName"]);
    menu.Items.Add(categoryItem);

    foreach (DataRow childItem in parentItem.GetChildRows("Children"))
    {
      MenuItem childrenItem = new MenuItem((string)childItem["ProductName"]);
      categoryItem.ChildItems.Add(childrenItem);
    }
  }


Refer this and check your loop
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900