経由でインストール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));
}
}
結果として、スタイルが設定されていない順序付けられていないリストを持つのは正常ですか。カスタム スタイルをページャーに適用するにはどうすればよいでしょうか。
ありがとう!