Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a paging solution for ASP.NET MVC that does paging in the database?

Most of the ASP.NET MVC paging solutions I have found by googling look like they get all rows from a database table in the form of a IEnumerable collection, perform some paging conversion on the IEnumerable collection, and then return the results to the view. I want to be able to page on the DB side but still have some paging class to do the page number calculations and HTML generation. Is there a solution out there that does this? Or are the ones i've been looking at do this, but i'm not seeing it because i'm looking at them wrong?

here's what i've been looking at:

  • http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/
  • http://www.codeproject.com/KB/aspnet/pagination_class.aspx
  • http://www.squaredroot.com/2009/06/15/return-of-the-pagedlist/
like image 348
gabe Avatar asked Jul 09 '09 17:07

gabe


People also ask

What is paging in asp net?

We use C# code to bind the SQL data with a GridView control and use the following simple steps to make your ASP.NET GridView control with paging enabled. The GridView control provides you with an easy way to display the number of items on a page without taking much space, with the help of paging.

How can we implement pagination in asp net core?

How to implement paging in ASP.NET Core Web API. In an empty project, update the Startup class to add services and middleware for MVC. Add models to hold link and paging data. Create a type to hold the paged list.

How do I navigate between pages in MVC?

We while creating MVC application need to navigate from one View to another. The usual and simple way that we use is to use HTML elements "a" with its href attribute set to a specific controller's action, this is most obvious way of navigating right!.


1 Answers

Look at the Gu's Nerdinner sample.

var upcomingDinners = dinnerRepository.FindUpcomingDinners();  
var paginatedDinners = upcomingDinners.Skip(10).Take(20).ToList(); 

Even though FindUpcomingDinners() gets all the upcoming dinners, the query isn't executed at the database until you call ToList() in the next line. And that is after you Skip 10 rows and only get
the next 20.

like image 178
jvanderh Avatar answered Sep 23 '22 23:09

jvanderh