MVC 4.0 Syntax Automatic paging

Source: Internet
Author: User

4.0 syntax to implement automatic paging requires only two methods, skip ()----Skip the specified element in the sequence, take ()-----Return the specified number of elements from the beginning of the sequence.

The general use of automatic paging is no refresh, you can display the data, with the local page encapsulation, each time the paging is asynchronous to obtain a partial page.

Shopbackdatacontextsc =New Shopbackdatacontext();//linq to SQL class

/// <summary> ///Automatic Paging/// </summary> /// <param name= "PageCount" >The first few pages</param> /// <returns></returns> PublicActionResult AutoPage (int?pagecurrent) { intPagesize=5;//How many pages are displayed per page intPagetotal=sc. Address.count ();//how many records are in total? intpagecount=pagetotal/PageSize; //A total of several pages if(pagetotal%pagesize!=0) {PageCount+=1; } varResult=sc. Address.skip (pagecurrent.value*PageSize). Take (PageSize). AsEnumerable (); //Show 5 data on page returnView (); }

MVC 4.0 Syntax Automatic paging

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.