本文介绍了如何将子项添加到asp菜单控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2张菜单制作菜单 **页面** PathId ParentId PathUrl PathName ** PagesAssigned ** AssignedId PathId RoleId
i have these 2 table for menu Making **Pages** PathId ParentId PathUrl PathName **PagesAssigned** AssignedId PathId RoleId
SELECT [Path].Menu_Id,dbo.[Path].Path_Detail, [Path].Path_Url, [Path].Sub_Menu_Id, pagesAssigend.roleId FROM pagesAssigend INNER JOIN [Path] ON pagesAssigend.pageNo = Path.Menu_Id WHERE (dbo.pagesAssigend.roleId = 1)通过以上查询,我使用hir \her角色ID确认指定用户的菜单。 和aspx文件中我有这个代码来填充asp菜单c ontrol
Through above query i confirming a menu for a specified user using hir\her role id. and in aspx file i have this code to fill asp menu control
int RoleNo = Convert.ToInt16(Session["RoleId"]); objLogin.Role_Id = RoleNo; DataTable dt = new DataTable(); dt = objLogin.MenuMaking(); GridView1.DataSource = dt; GridView1.DataBind(); foreach (DataRow dr in dt.Rows) { MenuItem objMenuItem = new MenuItem(); objMenuItem.Text = dr["Path_Detail"].ToString(); objMenuItem.NavigateUrl = dr["Path_Url"].ToString(); MenuBar.Items.Add(objMenuItem); }这个工作正常,但我想在父菜单下显示子菜单。我怎么能实现这个?
this is working fine but i want to show child menu too under it parent menu. How can i acheive this??
推荐答案有子菜单你只需将menuItems添加到menuItems ChildItems。 to have submenus you just add menuItems to a menuItems ChildItems. // Retrieve the root menu item from the Items // collection of the Menu control using the indexer. MenuItem homeMenuItem = NavigationMenu.Items[0]; // Create the submenu item. MenuItem newSubMenuItem = new MenuItem("New Category"); // Add the submenu item to the ChildItems // collection of the root menu item. homeMenuItem.ChildItems.Add(newSubMenuItem);
更多推荐
如何将子项添加到asp菜单控件
发布评论