Welcome to OGeek Q&A 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...