Paging demo upgraded to ASP.NET MVC RC

The sample project that belongs to the Paging with ASP.NET MVC post is upgraded to ASP.NET MVC RC. Get it from here.

No Trackbacks

4 Comments

  1. Edward Johnson

    When I click on the button for a page it renders the page but the highlighted (therefore current) page is always one higher than the one I clicked on.

    Haven’t traced it down but it seems that if I’m on page 2 and click on page 1 the logic is looking at the current page (currently 2), not the page requested

    Posted February 12, 2009 at 9:17 pm | Permalink
  2. Antonio Tirado

    Hi, I’m looking at your code and it seems that if you’re using an actual database you’d be querying it each time you requested a page. Is this so? How do would you get around this constant hammering using MVC?

    Thanks in advance!

    Posted February 17, 2009 at 7:57 am | Permalink
  3. @Antonio: yes, you’d be querying the database each time, but you have to make sure that the database only returns the data for a specific page.
    With Linq2SQL this happens automatically because the pager supports IQueryable. When using NHibernate or some other custom data access method, you have to query for the data for the specific page and also query for the total number results (totalCount). The totalCount value can be passed into the PagedList constructor, together with the data of the specific page.

    Posted February 17, 2009 at 8:57 am | Permalink
  4. Robert

    There seems to be a bug in paginator related to the fact that it does not shows proper “…” if, for example, are 122 items in datasource. Corresponding number of pages = 13.

    If current page is 1, the paginator will display 1,2,3,4,5,6,7,8,9,10 instead of 1,2,3,4,5,6,7,8…12,13.

    The same when current page is last page, the paginator displays 3,4,5,6,7,8,9,10,11,12,13 instead of 1,2…,6,7,8,9,10,11,12,13.

    Posted March 28, 2009 at 9:49 pm | Permalink