动态地将菜单项添加到母版页

问题描述:

我曾使用单独的css文件作为菜单。我想允许用户动态地将菜单项添加到母版页。你会一步一步给我打电话吗?我今天只需回答..

I had used separate css file for menu. I want to allow the user to add menu items to the master page dynamically. So will you tel me step by step? and I need answer today itself only..

你好Lata,



有这些专栏你的数据表(这里是menudt是我的数据表)MENU_ID,MENU_NAME,PAGE_NAME,PARENT_MENU_ID,MENU_LOCATION

尝试使用以下代码,



这里,menuBar是我的MasterPage的菜单控件。



Hi Lata,

Have a these columns in your datatable (here menudt is my Datatable) MENU_ID,MENU_NAME,PAGE_NAME,PARENT_MENU_ID,MENU_LOCATION
Try to use this following codes,

Here, menuBar is my MasterPage's Menu control.

DataRow[] drowpar = menudt.Select("ParentID=" + 0);                
 foreach (DataRow dr in drowpar)
 {                  
     menuBar.Items.Add(new MenuItem(dr["MenuName"].ToString(),
             dr["MenuID"].ToString(),"")); 
 }

 foreach (DataRow dr in menudt.Select("ParentID >" + 0))
 {

     MenuItem mnu = new MenuItem(dr["MenuName"].ToString(),
                    dr["MenuID"].ToString(),
                    "", dr["MenuLocation"].ToString());
   
     menuBar.FindItem(dr["ParentID"].ToString()).ChildItems.Add(mnu);
 }





问候,

BlueSathish



Regards,
BlueSathish