Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

asp.net - Creating menus dynamically in web application

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 it dynamically from sql table.. help me with simple application which loads a menu control dynamically and i can develop mine using those concepts....

thank u very much

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...