Currently, I'm using a strategy found on many blog posts. Basically, the URL contains the page number (e.g. /Users/List/5 will give you the users on page 5 of your paged list of users). However, I'm not running into a situation where one page must list two separate paged lists. How do I go about doing this using ASP.NET MVC? Do I simply provide two url parameters (e.g. /Users/List?page1=1&page2=2)? Is there a better way by using partial views?
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.
This is what custom paging is all about i.e. fetching only required data from database. To enable Custom paging we need to explicitly set AllowCustomPaging property of DataGrid control to True. Use PageSize property to set the number of records to be displayed per page.
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.
Ignoring routes for just a minute, you'll just keep the state of the 2 different pages in the URL as querystring parameters.
mysite.com/foo?list1page=2&list2page=8
Then you build the data/pagers accordingly. The pager links will just update the url.
You can get creative with routes to create more friendly URLs, but I think querystring params are perfectly acceptable here.
I've found ASP.NET MvcPager on the official asp.net site.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With