1 The Home code is as follows
Public classHomecontroller:controller {// //GET:/home/Model1container db =NewModel1container (); PublicActionResult Index (intPageIndex =1) { varModel = db. Student.orderby (p = p.id). Topagedlist (PageIndex,3); returnView ("Index", model); } PublicActionResult prodectlist () {returnPartialview ("_prodectlist"); } }
The 2.Index code is as follows
@{ "Index";} @using webdiyer.webcontrols.mvc@html.partial ("_prodectlist", Model) @model Webdiyer.WebControls.Mvc.PagedList<MvcApplication1.Student>new Pageroptions () { }) @Model. Totalitemcount message @Model. CurrentPageIndex/@Model. Totalpagecount
3. Some view codes are as follows
@model webdiyer.webcontrols.mvc.pagedlist<mvcapplication1.student><table> @foreach ( var inch Model) { <tr> <td> = item. Id) </td> <td> = item. Name) </td> <td> = item. Sex) </td> </tr> }</table>
4. The results of the operation are as follows
Mvcpager Basic use of the page