如何将子项添加到asp菜单控件

编程入门 行业动态 更新时间:2024-10-22 09:42:49
本文介绍了如何将子项添加到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菜单控件

本文发布于:2023-11-23 15:55:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622032.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   如何将   菜单   asp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!