编程语言
首页 > 编程语言> > Asp.Net Core 使用X.PagedList.Mvc.Core分页

Asp.Net Core 使用X.PagedList.Mvc.Core分页

作者:互联网

1.Nuget包添加引用: X.PagedList.Mvc.Core

2.View: 

@model X.PagedList.IPagedList<CodeFirstCore.Models.Users>
@using X.PagedList.Mvc.Core;

----------------------------------------------------------------------------------------

@foreach (var item in Model)
{
  <tr>
    <td>@item.Id</td>
    <td>@item.Name</td>
  </tr>
}

@Html.PagedListPager(Model, page => Url.Action("UserList", new { page }))

3.Controller

using X.PagedList;

public ActionResult UserList(int page = 1, int pagesize = 15)

{
  var query = db.Device.ToList();

  return View(query.ToPagedList(page, pagesize));
}

 

 

标签:Core,Asp,int,item,Mvc,PagedList,page
来源: https://www.cnblogs.com/vipsoft/p/12891031.html