Click here to Skip to main content
15,123,923 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have the menu in my application which retrieves the menu names from the database
when I run the application.
But I want to display the same menu names dynamically(before running the application).

The following is the html for menu:

<uc2:Menu ID="Menu1" runat="server">


Can any one Please suggest me on this.

Regards,
Raj
Posted
Updated 19-May-11 20:30pm
v2
Comments
walterhevedeich 20-May-11 2:51am
   
Not clear? What do you mean by dynamic? Isnt retrieving menu names from the database already considered as dynamic?

u can write the hard code in page load method...
   
Comments
Raj.rcr 20-May-11 5:51am
   
No... I am given this task in such a way that I should not hardcode the menu names.. But they shoud be retreived from the database and appear on the dynamic web page.. i.e, Before I run the application
Try the following sample code :

MenuItem rootitem = new MenuItem("Ariticles");
            MenuItem childItem = new MenuItem("Ariticle 1");
            MenuItem childItem2 = new MenuItem("Ariticle 2");
            
            childItem.NavigateUrl = "sample.aspx";
            childItem2.NavigateUrl = "sample2.aspx";

            rootitem.ChildItems.Add(childItem);
            rootitem.ChildItems.Add(childItem2);
            
            Menu1.Items.Add(rootitem);
<pre>
   
v2

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