Answer the question
In order to leave comments, you need to log in
ASP.NET Core how to convert pagination(PagedList) to ajax?
index.cshtml:
@model X.PagedList.IPagedList<Employees.Models.Employee>
@using X.PagedList.Mvc.Core;
<table class="table" id="Table">
<thead>
<tr>
<th>Имя</th>
<th>Возраст</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@item.Name</td>
<td>@item.Age</td>
</tr>
}
</tbody>
</table>
<div class="pagination">
Страница @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) из @Model.PageCount
@Html.PagedListPager(Model, page => Url.Action("Index", new { page }))
</div>
public IActionResult Index(int? page)
{
int pageSize = 3;
int pageNumber = (page ?? 1);
return View(employeeRepository.GetEmployees().ToPagedList(pageNumber, pageSize));
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question