1. Installation
2.In the NuGet package management console, enter Install-package PAGEDLIST.MVC installation pagedlist and PAGELIST.MVC;
3.
@{Layout = null;} @model pagedlist.ipagedlist<webcms.model.admin> <! DOCTYPE html>
4. Control inside is quoted = "Using Pagedlist;"
<summary>
///Administrator account
///</summary>
///<returns></returns>
//int Adminid = Convert.ToInt32 (session["Adminid"));
list<admin> list = new Adminmanager (). Getadmininfo (Adminid);
viewdata["showadmin"] = list;
Public ActionResult adminaccount (int page=1)
{
const int pageSize = 2;
int Adminid = Convert.ToInt32 (session["Adminid"]);
list<admin> list = new Adminmanager (). Getadmininfo ();
if (list = = null)
{return
httpnotfound ();
}
viewdata["showadmin"] = list;
var iuser = list. Topagedlist (page, pageSize);
viewdata["Showsystemlog"] = list;
Return View (Iuser);
}
5.
Each page @Model. pagesize.tostring () records, a total of @Model. Totalitemcount.tostring () records. viewbag.totalrecords = 0 0:model.pagenumber) page, a total of @Model. PageCount page. Or
Each page @Model. PageSize Records, a total of @Model. Totalitemcount Records. Model.pagecount < Model.pagenumber 0:model.pagenumber page for a total of @Model. PageCount page.
The purpose of this conditional expression is to prevent a record of 0 from appearing, with a total number of pages 0, and currently on page 1th.
In Pagedlist.mvc, the ipagedlist type has its own paging parameters such as the total number of records in the collection, the maximum number of records per page.
@Model. PageSize refers to the maximum number of records per page set.
@Model. The total number of Totalitemcount records,
@Model. PageCount Total Pages,
@Model. PageNumber the first few pages,
@Model. Count () The number of records that are contained on the current page.
@Html. Pagedlistpager (Model, page => url.action ("Index",
new {page, SortOrder = Viewbag.currentsort, SearchString = viewbag.searchstring})
Html.pagedlistpager (model,url,pagedlistrenderoptions) Paging helper method new The pagedlistrenderoptions () parameter allows you to customize the display format,
such as:
@Html. Pagedlistpager (Model, page => url.action ("Index", new { Page}), new Pagedlistrenderoptions () {Linktofirstpageformat = "Home", Linktonextpageformat = "Next page", Linktopreviouspagefor Mat = "Prev", Linktolastpageformat = "Last", Displayitemsliceandtotal = False, Maximumpagenumberstodisplay = 3})
This section comes with http://www.cnblogs.com/liuyuanhao/p/4943940.html
6. Spit out my current computer, real card, and so on work must first change a computer, ╭ (╯^╰)