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