Hi All,
I'm trying to create a master page with menu control that will populated dynamically from the database. While populating menu I don't wish create an XML file for the purpose.
Printable View
Hi All,
I'm trying to create a master page with menu control that will populated dynamically from the database. While populating menu I don't wish create an XML file for the purpose.
you can use the asp:Literal control to apply dynamic html
Code:StringBuilder menu = new StringBuilder();
menu.AppendLine("<ul>");
List<MyObject> list = SelectDataFromDB();
foreach(MyObject o in list){
menu.AppendLine(string.Format("<li><a href=\"{0}\">{1}</a></li>", o.Url, o.Text)); //asuming that Url and Text are values you select from the DB
}
menu.AppendLine("</ul>");
literalMenu.Text = menu.ToString();