[RESOLVED]Best industry used approach to implement paging in MVC

Hi all,

I need to implement paging on MVC4 project. I have come across multiple solutions for the same on the web but couldn’t decide what would be the best one to choose or say which is widely used as a industry standard.

I have around 50, 000 records in the database that satisfy the criteria and page size is 50. I want to hit the DB and load only specific 50 records each time whenever user selects a page.

Suggestions pls???

MVC is a presentation framework, it doesn’t concern itself with data paging.  If you’re using Entity Framework then you can look at this for examples of paging

http://msdn.microsoft.com/en-us/magazine/gg650669.aspx

I don’t think it is all that efficient if you have a lot of data though, you’d need to examine the sql that gets created.  Or you can do your own paging at an SP level

http://www.codeproject.com/Articles/590341/Stored-Procedure-with-Sorting-Paging-and-Filtering

http://stackoverflow.com/questions/15676685/paging-of-records-using-sql-server-stored-procedure

Thanks for the reply AidyF.

Would you recommend using PageList.MVC NuGet Package over using SP?

You have to have a dig into the queries things execute and how they work to make sure it is compatible with the amount of data you have.  Some jQuery-based pagers simply get all data and page through it in code, which can be fast but isn’t good if you have
hundreds of thousands of items.  Some will execute ajax requests back to retrieve each page, and as long as your data retrieval is efficient this would be the best ajax-related approach.  But again how you implement server-side paging also has an impact as
things like .Skip().Take() could result in a lot of waste SQL resources and slow queries.  If you have a lot of data you need a solution that doesn’t get every result and page in-memory, and you need to make sure that the code you use to get the data from
your database is also efficient.

Leave a Reply