views:

48

answers:

2

Hi,

Every time you search for post on SOF, you can browse through the result with page-navigation feature. How do I create a Paging feature like SOF? I like that feature a lot.

+1  A: 
    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:


EDIT: For Web-forms look at this Tutorial Series

Asad Butt
Hey, How to do it with WebForm? Thanks.
Angkor Wat
have a look at EDIT, it is pretty easy
Asad Butt