Pagination
Pagination is used to divide content, usually lists, into separate pages. For example, when scaffolding a List view, the default scaffolding template generates a table that contains a row for each item in the collection you pass into the view. This is fine for small amounts of data, but if the list contains hundreds of items, your page will take a very long time to load. Ideally, you would like to split your list view into a manageable 5 to 10 items per page view.
In the first edition of this book we used the PagedList.Mvc
NuGet package to make paging using Bootstrap 3 easier. This package is no longer maintained, but there is a drop-in replacement library available on NuGet called X.PagedList
.
Unfortunately, neither NuGet Packages would work, because of their dependencies on System.Web
, which was removed from ASP.NET Core. In the following example we'll use an open source library called cloudscribe.Web.Pagination
to create a paged list using Bootstrap 4.
To create the paged list...