Click here to Skip to main content
15,908,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,I have a asp menu which have dynamic genrated first and second level nodes in it. now if i click on first level node then it shows the 2nd level node. then i select my second level node.. so then how can i acess selectedvalue for 2nd level nodes.?? any solution??
i treid menuitem_click() event but it gives me only firstlevel node selected value.. :(
Posted
Comments
Nelek 3-Apr-12 13:33pm    
Can you post the snippet of code refered to the problem?
Sergey Alexandrovich Kryukov 3-Apr-12 14:28pm    
Also, tag the application type or UI library you use. WPF? Forms? Silverlight? ASP.NET? Mobile? What?
--SA

1 solution

There is no such event as "menuitem_click()" and there is no essential difference between menu levels. These two facts are something you need to know first. Perhaps you need to learn how events and delegate instances work. We cannot see if you screw up anything based on your information.

—SA
 
Share this answer
 
Comments
KUNWAR999 3-Apr-12 14:39pm    
here is the code..
protected void Page_Load(object sender, EventArgs e)
{
DataSet dst = dm.getcategories();
Menu1.Items.Clear();
foreach (DataRow masterRow in dst.Tables["category"].Rows)
{
MenuItem masterItem = new MenuItem((string)masterRow["category"]);
masterItem.Value=masterRow["ID"].ToString();
Menu1.Items.Add(masterItem);
foreach (DataRow childRow in masterRow.GetChildRows("Children"))
{
MenuItem childItem = new MenuItem((string)childRow["subcategory"]);
childItem.NavigateUrl = "Page2.aspx";
Session["category"] = Convert.ToInt32(masterRow["ID"]);
Session["subcategory"] = Convert.ToInt32(childRow["CID"]);
masterItem.ChildItems.Add(childItem);
}
}
}
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
MenuItem m = Menu1.SelectedItem;
Session["id"] = Convert.ToInt32(Menu1.SelectedValue);//it takes level1 node of menu,i need 2nd level menu id,, subcategory of category as u can see in code now..
Response.Redirect("Page2.aspx");

}

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