Method-:
1, the method of using Pagedlist to turn pages in service
Writing one:
<summary>
More on the Policy and Regulation list page
</summary>
<param name= "page" > page number of pagination </param>
<param name= "Sid" > Department Code </param>
<returns></returns>
Public pagedlist<c_newss> Lists (int? page)
{
EXPRESSION<FUNC<C_NEWSS, bool>> filter = T = = true;
int pageSize = 10;//The number of displays per page
Filter = filter. and (t = T.news_kind ==171);
using (jy_villageentities db = new Jy_villageentities ())
{
Return DB. C_newss.where (filter). OrderByDescending (t=>t.pub_date). Topagedlist (page 1, pageSize);
}
}
Two:
Public pagedlist<p_finances> GETPAGEDLISTBYDWDM (string dwdm, int? page)
{
int pageSize = 10;
using (jy_villageentities db = new Jy_villageentities ())
{
Return DB. P_finances.where (item = Item). DWDM = = DWDM). OrderByDescending (item = Item). Year). ThenByDescending (item = Item). Month). Topagedlist (page 1, pageSize);
}
}
2, the method of invoking page flipping in action
<summary>
Policies and regulations more list data
</summary>
<param name= "Classno" ></param>
<param name= "Sid" ></param>
<returns></returns>
Public ActionResult List (int? page, int? sid)
{
Viewdata.model = Homeservice.morelist (Classno, sid);
Viewdata.model = homeservice.lists (page);
return View ();
}
3, using In view
@using WEBDIYER.WEBCONTROLS.MVC
@model webdiyer.webcontrols.mvc.pagedlist<community.site.models.c_newss>
<div id= "PageContent" >
<ul>
foreach (var item in Model)
{
<li><a href= "@Url. Action (" News ", new {Newsno = item.id})" ><span>@ (item. Createon) </span>@ (item. Title) </a></li>
}
}
</ul>
</div>
Use the Mvcpager plugin to directly use the @html.pager control
@* @Html. Pager (Model, new pageroptions {pageindexparametername = "page", CssClass = "pagination"}) *@
Use the button you wrote with the following
<div class= "page",
<span class= "Pageleft" ><a href= "@ Url.action ("List", new {page = Model.currentpageindex = = 1?) "": (model.currentpageindex-1). ToString ()}) "
</a></span><span class=" Pagenum "> @Model. CurrentPageIndex/@ Model.totalpagecount</span>
<span class= "pageright" ><a href= "@Url. Action (" List ", new {page = ( Model.currentpageindex + 1)}) "></A></SPAN>
</div>