More rights mean more responsibilities. In MVC, we almost no longer use various controls from Drag and Drop, so we are no longer limited by the functions provided by these controls, but of course, the benefits and convenience brought by these controls are lost. For example, GridView and its paging function. This article will use the defered execution feature of LINQ to implement a general PagedList for paging and navigation, so as to implement the ASP. net mvc paging function.
ASP. net mvc paging-CONTENT
To enable PagedList to have paging and navigation functions, we need to know the total number of rows of data and how many rows need to be displayed. Therefore, you can define such an interface.
To enable this generic PagedList to be "generic", you need to use generics .. Net has provided a good base class, we can inherit it, and at the same time implement IPagedList Interface
The last code in the PagedList constructor is explained as follows: index is the number of pages calculated from 0, which can be Null. pageSize is the number of records displayed on each page. Finally, the call to ToList () will make the IQueryable be executed, and the returned List will be added to the PagedList.
ASP. net mvc paging-Application
The PagedList is basically complete and is applied in practice. In the page file, you can set CSS based on the PagedList data to implement paging and navigation functions.
OK, We have done here. ASP. NET MVC paging implementation.
I didn't expect a good way to add the Controller information here, so I had to work hard for the moment.
- Add custom routes for ASP. net mvc applications
- Learning how to use ASP. net mvc Routing
- Analysis of URL Rewrite in ASP. NET
- Introduction to ASP. net mvc Framework
- Introduction to MvcAjaxPanel in ASP. NET MVC