开发者

asp:Repeater and ActionLink

Am I able to use asp:Repeater and Html.ActionLink together for creating a dynamic menu? Or is th开发者_StackOverflow中文版ere any other methods that I can use it?

Note: I'm getting the menu list from SQL.


I'm going to assume you are using ASP MVC 1 or 2 if you're using HTML.ActionLink. If that is the case, what you'll want to do is pass your list of items to the view through your Model or ViewModel and in the view, create a for each loop to display the items instead of using a repeater control.

Another option is to create a partial view that you pass your list of menu items to and create the for each loop in there then render the partial where ever you need to show your menu.

if you put the menu in the Master Page it will automatically show up every where.


I think you can, there are a lot of information on the web about how to use asp controls in MVC code. also, MVC seems to have its own repeater: http://davidhayden.com/blog/dave/archive/2009/04/07/ASPNETMVCControlsASPNETMVCFuturesRepeaterControlExample.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜