Kaan
Kaan

Reputation: 896

asp:Repeater and ActionLink

Am I able to use asp:Repeater and Html.ActionLink together for creating a dynamic menu? Or is there any other methods that I can use it?

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

Upvotes: 0

Views: 286

Answers (2)

Justin
Justin

Reputation: 1438

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.

Upvotes: 1

akonsu
akonsu

Reputation: 29536

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

Upvotes: 0

Related Questions