开发者

Building pagination in MVC: Is there anyway to get something like an Html.HyperLinkFor

开发者 https://www.devze.com 2023-02-05 07:29 出处:网络
What I mean by that is atype element that will have a label based on a value in my viewModel and also be able to subm开发者_如何学编程it that value back up to the viewModel so it can grab new results

What I mean by that is a type element that will have a label based on a value in my viewModel and also be able to subm开发者_如何学编程it that value back up to the viewModel so it can grab new results based on Current Page and Page Size. This is for creating a gridview in MVC that supports pagination.

None of the examples I've seen of MVC so far have had anything resembling a gridview. It's important that I create my own paging and not use any built in paging mechanisms or third party controls or html helpers or the like


I'd go with ActionLink. To build Urls you can either use Url.Action or Html.BuildUrlFromExpression(c => c.conTrollerAction)


If you use T4MVC, you will get some nice helpers that do exactly what you are looking for.

Something along the lines of:

<a href="<%: Url.Action(MVC.MyController.MyAction(Model.ActionMethodParam1, Model.ActionMethodParam2)) %>">

You can also use the Html.ActionLink helper:

<%: Html.ActionLink("Link Name", MVC.MyController.MyAction(Model.ActionMethodParam1, Model.ActionMethodParam2)) %>

T4MVC is a great little library that I use in every MVC app.

0

精彩评论

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

关注公众号