Every time you search for post on SOF, you can browse through the result with page-navigation feature. How do 开发者_如何学GoI create a Paging feature like SOF? I like that feature a lot.
using MvcContrib.Pagination;
public ActionResult Index(int? page)
{
var pageNo = page?? 1; // default to page 1
var someEnumerable = GetData(); // returns your collection
var cutomPage =
PaginationHelper.AsPagination<SomeObject>(someEnumerable , pageNo);
return View(“Index”, CustomPage);
}
Also have a look at this tutorial: NerdDinner Step 8: Paging Support
var paginatedDinners = upcomingDinners.Skip(10).Take(20).ToList();
references:
- Powerful but easy paging with ASP.NET MVC
- How do you implement paging in ASP.NET MVC?
EDIT: For Web-forms look at this Tutorial Series
- Paging and Sorting
Use the powerful DataPager control.
Here's a tutorial:
http://west-wind.com/weblog/posts/127340.aspx?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+RickStrahl+%28Rick+Strahl%27s+WebLog%29
精彩评论