". NET MVC paging". NET MVC uses pagelist paging __.net

Source: Internet
Author: User
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, ╭ (╯^╰)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.