Creating menus dynamically in web application

后端 未结 2 1045
醉酒成梦
醉酒成梦 2020-12-22 01:15

Im creating a web application in asp.net visual studio 2008.. in my application, i have manually created a menu control.. since, the menus changes by needs, i wish to load i

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-22 01:57

    load your menu to a datatable. then create a repeater in your ascx page (i guess your menur is a user control) create the template for the repeater. bind the datatable as the datasource for that repeater. and there you go. a simple dynamic menu.

    dont forget to do a cache on your control. or cache the datatable. so you wont open a connection to the database on every request for a page on your site

    here is some examples for using a repeater :

    http://articles.sitepoint.com/article/asp-net-repeater-control http://www.w3schools.com/aspnet/aspnet_repeater.asp http://www.asp101.com/articles/john/repeater/default.asp

提交回复
热议问题