ASP. net mvc paging Based on ipagedlist

Source: Internet
Author: User

I wrote an MVC paging article last year.

I used an ASP. NET MVC file to share it by page.

Now release a release version

The ipagedlist used in it is hard to remember where to copy it. Haha

Here I will not take the ipagedlistCodePaste it out. You can download the demo.

 

Data paging in the background

 Public  Actionresult  Index  ([  Defaultvalue  (1)]  Int  P  ,[  Defaultvalue  (10)] Int  Pagesize  ){  VaR  Model  =  Database  .  List  .  Orderbydescending  (  Z  =>  Z  .  ID  ). Topagedlist  (  P  -1,  Pagesize  );  Return  View  (  "Index"  ,  Model  );} 

I prefer to use defaultvalue recently.

Of course, it can also be written

 Public  Actionresult  Index (  Int  ?  P  ,  Int  ?  Pagesize  ){  P  =  P  ?? 1;  Pagesize  =  Pagesize  ?? 10;  VaR Model  =  Database  .  List  .  Orderbydescending  (  Z  =>  Z  .  ID  ).  Topagedlist  (  P  -1, Pagesize  );  Return  View  (  "Index"  ,  Model  );} 

Here, the first parameter in the topagedlist extension method is index.

I am too lazy to change it to page, so I used the p-1.

 

Console call

<%@PageLanguage="C #"Masterpagefile="~ /Views/shared/site. Master"
 
Inherits="System. Web. MVC. viewpage <mvcdemo. ipagedlist <mymodel>"%>

     <%  =  Html  . Pagerbar  (  Viewdata  .  Model  )  %>    <  Table  > <  Thead  > <  Tr  > <  Th  >  ID </  Th  > <  Th  >  Surname? Name?  </  Th  > <  Th  >  Mailbox box?  </  Th  > <  Th  >  ? Persons? Master region page 3 </  Th  > <  Th  >  Súri?  </  Th  > <  Th  >  & Nbsp;  </  Th  > </  Tr  > </  Thead > <  Tbody  >  <%  Foreach  (  VaR  Item  In  Viewdata  .  Model  ){  %>    <  Tr > <  TD  >  <%  =  Item  .  ID  %>  </  TD  > <  TD  >  <%  =  Item  . Name  %>  </  TD  > <  TD  >  <%  =  Item  .  Email  %>  </  TD  > <  TD  > <%  =  Item  .  URL  %>  </  TD  > <  TD  >  <%  =  Item  .  Birthday  .  Tow.datestring ()  %>  </  TD  > <  TD  >  <%  =  Html  .  Actionlink  (  "Edit"  ,  "Edit"  ,  New {  ID  =  Item  .  ID  }, 
    New  {  @ class  = " D " ,  width  =600})  %>     TD  >
     tr  > <% } %>       tbody  >  table  > 

 

Style controls are similar to those in the previous article. I will not talk about them here.

 

In Demo:

 

Download Demo:/files/francis67/mvcdemo.rar

Related Article

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.