display menu items based on database table values
-
i want to display a menu on user home page. The menu items will be added / updated by admin(client) in admin section after I deploy the project to him. He would be shown a page on which he would add the various menu items. These would be stored into databse and then displayed on menu at home page. Can someone help me with the code for implementing this?
-
i want to display a menu on user home page. The menu items will be added / updated by admin(client) in admin section after I deploy the project to him. He would be shown a page on which he would add the various menu items. These would be stored into databse and then displayed on menu at home page. Can someone help me with the code for implementing this?
Yes, you can do it very easily. You have use menu as dyanmic. Here is two complete example, Building a Database Driven Hierarchical Menu using ASP.NET 2.0[^] and Populating Menu Control in ASP.NET 2.0 - using different data sources[^] Hope this will help you :-D
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you. View My Latest Article
-
i want to display a menu on user home page. The menu items will be added / updated by admin(client) in admin section after I deploy the project to him. He would be shown a page on which he would add the various menu items. These would be stored into databse and then displayed on menu at home page. Can someone help me with the code for implementing this?
Create a table with fields MenuCaption,NavigateUrl etc the fields without navigateurl should be update able. then on home page retrieve all the fields and add it to menu as menuitem. Like this
SqlConnection con=new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("select * from mainMenu", con);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
foreach (DataRow row in dt.Rows)
{
MenuItem itm = new MenuItem(row["MenuCaption"].ToString(), "value", "", row["NavigateUrl"].ToString());
Menu1.Items.Add(itm);
}
}