Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mikebrind
Created October 2, 2018 15:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikebrind/6229c242af993d62ce342b5f73d5cf84 to your computer and use it in GitHub Desktop.
Save mikebrind/6229c242af993d62ce342b5f73d5cf84 to your computer and use it in GitHub Desktop.
@page
@model PaginationModel
<h2>Pagination Example</h2>
<table class="table table-striped">
@foreach (var item in Model.Data)
{
<tr>
<td>@item.Id</td>
<td>@item.FullName</td>
<td>@item.Country</td>
<td>@item.Email</td>
<td>@item.CreatedAt</td>
</tr>
}
</table>
<div>
<ul class="pagination">
@for (var i = 1; i <= Model.TotalPages; i++)
{
<li class="page-item @(i == Model.CurrentPage ? "active" : "")">
<a asp-page="/pagination" asp-route-currentpage="@i" class="page-link">@i</a>
</li>
}
</ul>
</div>
@shitalumare
Copy link

I am referring to your code.how to use sorting and paging here? I have added .cs code but i am getting current page 0 on click of 2nd page
@for (var i = 1; i <= Model.TotalPages; i++)
{
<li class="page-item @(i == Model.CurrentPage ? "active" : "")">
@i

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment