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 DeviceList(int page = 1, int pagesize = 15)

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

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

posted @ 2018-09-17 15:58  超级驼鹿  阅读(1630)  评论(0编辑  收藏  举报
/*