Asp.net mvc paging mechanism

淺唱寂寞╮ 提交于 2019-12-29 06:32:22

问题


is there some elegant way, ideally with jquery plugin like pager 1 or pager 2 how to implement paging with asp.net mvc? I am trying to go over partial views, but so far unsucessfully. Where should I store the loaded grid data? And how to respond on the page selection with just a partial refresh?

Thanks in advance.


回答1:


Try this article out, looks pretty handy - he uses a custom Html extension method. Also, check this SO question.




回答2:


The MVC Contrib Grid comes with paging functionality. Might be worth a look.




回答3:


I suggest checking out ScottGu's NerdDinner as he shows how to make a pager with ASP.NET MVC there.

One way you can do it is to transmit the result range via the URL, i.e.

http://domain.com/Products/List/0-10

...could show 10 products starting at 0. If you had many search fields, another way would be to have a contoller with a List action returning JSON, XML or an HTML table that you could call using an AJAX GET.

But I highly suggest checking out NerdDinner, as he has an example of how to do this.




回答4:


You wouldn't store the loaded data. MVC allows you to keep the view stateless, so the call back to the controller for the next page needs to include the page number being requested. Then you just return the rows required. You could also use AJAX for that.



来源:https://stackoverflow.com/questions/1293799/asp-net-mvc-paging-mechanism

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!