asp.net-mvc-4paginationpagedlist

How to use PagedListPager with Model having List of object in MVC 4


I have a Model containing the below property:

public List<AutoAdListVM> advertlist { get; set; }

In my view this List comes with multiple records, and I want to display 10 records per page by performing paging, now I don't have idea how to use PagedListPager to achieve this functionality. Please help me out.

I am display records as with foreach loop as Model.advertlist


Solution

  • The PagedList library package can be added to your MVC project through Nuget and is easy to use. Here is the GitHub page that can walk you through both the install and the usage of this library.

    If you need additional examples, the asp.net site also has an in depth tutorial on paging that can be accessed here. Just scroll down to the "Add Paging to the Students Index Page" section and follow along with their example.