我通过. PagedList
_ 然后我以这种方式使用它:PagedList.Mvc
NuGet
@using PagedList;
@using PagedList.Mvc;
@model IPagedList<Employee>
@{
ViewBag.Title = "ListEmployees";
}
<h3>All Employees (@ViewBag.TotalEmployees)</h3>
@if(Model.Count > 0)
{
foreach(var item in Model)
{
Html.RenderPartial("Employee.Card", item);
}
@Html.PagedListPager((IPagedList)Model, page => Url.Action("List", new { page = page }), PagedListRenderOptions.Minimal)
}
else
{
@: no records were found. Sorry
}
使用控制器内部的代码:
public class EmployeeController : Controller
{
private IRepository<Employee> repository;
private Int32 PageSize = 10;
public EmployeeController(IRepository<Employee> repository)
{
this.repository = repository;
}
public ActionResult List(Int32? page)
{
var set = repository.Get();
ViewBag.TotalEmployees = set.Count();
return View(set.ToPagedList(page ?? 1, PageSize));
}
}
结果是没有样式的无序列表是正常的吗?然后我如何将自定义样式应用于寻呼机?
谢谢!