menu index of a certain menu item....
ASP.NET
2
Posts
2
Posters
0
Views
1
Watching
-
Hi to all, I am trying to add the menu items dynamically. But I am stucked in problem. I am unable to find the index of the menu items where menu text is "something".
public void populate\_menu() { DataSet ds = GetMenuData(); foreach(DataRow drow in ds.Tables\["CATEGORY"\].Rows) { MenuItem masteritem = new MenuItem((string)drow\["category\_name"\]); name = masteritem.Text; get\_id(); par\_id = Convert.ToInt32 (ViewState\["p\_id"\]); if (par\_id == 0) { Menu1.Items.Add(masteritem); } else { //now find the category whose category\_id is par\_id get\_category\_name(); ca\_name = ViewState\["cname"\].ToString(); //get the menu index where category name is "ca\_name" //then under that category, add this sub category Menu1.Items\[0\].ChildItems.Add(masteritem); } } }
please assist me..
cheers, sneha
-
Hi to all, I am trying to add the menu items dynamically. But I am stucked in problem. I am unable to find the index of the menu items where menu text is "something".
public void populate\_menu() { DataSet ds = GetMenuData(); foreach(DataRow drow in ds.Tables\["CATEGORY"\].Rows) { MenuItem masteritem = new MenuItem((string)drow\["category\_name"\]); name = masteritem.Text; get\_id(); par\_id = Convert.ToInt32 (ViewState\["p\_id"\]); if (par\_id == 0) { Menu1.Items.Add(masteritem); } else { //now find the category whose category\_id is par\_id get\_category\_name(); ca\_name = ViewState\["cname"\].ToString(); //get the menu index where category name is "ca\_name" //then under that category, add this sub category Menu1.Items\[0\].ChildItems.Add(masteritem); } } }
please assist me..
cheers, sneha
I guess you need to maintain a value path and work with Menu.FindItem()[^] method. Other way is to recursively search the menu items and sub items until you get the required item.
Navaneeth How to use google | Ask smart questions