The sample project that belongs to the Paging with ASP.NET MVC post is upgraded to ASP.NET MVC RC. Get it from here.
Tagged: ASP.NET MVC, Paging
The sample project that belongs to the Paging with ASP.NET MVC post is upgraded to ASP.NET MVC RC. Get it from here.
Tagged: ASP.NET MVC, Paging
No Trackbacks
4 Comments
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
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!
@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.
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.