Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle paging in asp.net mvc?

I'm using asp.net mvc. I want to add paging to the list of records. Please help with any links or sample code.

Thanks.

like image 942
Ravi Avatar asked Apr 13 '09 05:04

Ravi


People also ask

How do you apply paging to a list?

In order to make paging worth the effort, you need to move it into the database. Change your method to accept page size and number, and use them to change the SQL to retrieve the list for a single page. Don't forget to force ordering on your sql read, otherwise the same data might appear on different pages.

How do I Paginate in C#?

The C# pagination logic is contained in a single Pager class that takes the following constructor arguments: totalItems (required) - the total number of items to be paged. currentPage (optional) - the current active page, defaults to the first page. pageSize (optional) - the number of items per page, defaults to 10.


1 Answers

Paging with ASP.NET MVC Demo

alt text
(source: taiga.nl)

like image 109
KingNestor Avatar answered Oct 28 '22 00:10

KingNestor