Click here to Skip to main content
15,063,085 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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..
Posted

1 solution

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.

C#
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);
 }


Regards,
BlueSathish
   
Comments
bluesathish 20-Jan-15 3:49am
   
I'm just post the sample code, you just go through it. Learning is the first step to becoming master of a specified field. So just try it by yourself. :-)

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