如何在ASP.NET MVC实现分页? [英] How do you implement paging in ASP.NET MVC?

查看:104
本文介绍了如何在ASP.NET MVC实现分页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我使用的许多博客文章中发现的战略。基本上,URL包含页码(如/用户/列表/ 5会给你寻呼的用户列表中第5页的用户)。不过,我还没有遇到的情况,其中一个页面中必须列出两个独立的分页列表。我怎么去这样做使用ASP.NET MVC?难道我只是提供两个URL参数(例如,/用户/列表第1页= 1&放大器;第2页= 2)?有没有使用部分景色更好的办法?

Currently, I'm using a strategy found on many blog posts. Basically, the URL contains the page number (e.g. /Users/List/5 will give you the users on page 5 of your paged list of users). However, I'm not running into a situation where one page must list two separate paged lists. How do I go about doing this using ASP.NET MVC? Do I simply provide two url parameters (e.g. /Users/List?page1=1&page2=2)? Is there a better way by using partial views?

推荐答案

忽略路线仅需一分钟,你刚在URL作为查询字符串参数2不同页面的状态。

Ignoring routes for just a minute, you'll just keep the state of the 2 different pages in the URL as querystring parameters.

mysite.com/foo?list1page=2&list2page=8

mysite.com/foo?list1page=2&list2page=8

然后,你相应地构建数据/寻呼机。寻呼机链接将只更新网址

Then you build the data/pagers accordingly. The pager links will just update the url.

您可以发挥创意与途径创造更多友好的URL,但我想查询字符串PARAMS是完全可以接受的位置。

You can get creative with routes to create more friendly URLs, but I think querystring params are perfectly acceptable here.

这篇关于如何在ASP.NET MVC实现分页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆