I have added ReflectionIT.Mvc.Paging from NuGet Link but I have a problem.
In a controller i have 2 methods, Index and Organizations. When I am on the view of Orginizations and press page with number "2" in controller goes to index and not on Organizations method. How to force it to go on a method i want?
Controller:
public IActionResult Index()
{
return View();
}
public async Task<IActionResult> Organizations(int page=1)
{
var userlist = _context.Users.Include(u => u.UserRoles).ThenInclude(u => u.Role).Where(o => o.UserRoles.All(r => r.Role.Name == "Company") && o.IsActive == true).AsNoTracking().OrderByDescending(o => o.Company);
var model = await PagingList.CreateAsync(userlist, 2, page);
return View(model);
}
View:
@model ReflectionIT.Mvc.Paging.PagingList<CharityProject.Models.ApplicationUser>
@using ReflectionIT.Mvc.Paging
@addTagHelper *, ReflectionIT.Mvc.Paging
@{
ViewData["Title"] = "Organizations";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="container py-lg-5 py-md-5 py-sm-4 py-4">
<h2 class="pageTitles">Organizations</h2>
<div class="row">
<nav aria-label="NewsFeed navigation example">
@await this.Component.InvokeAsync("Pager", new { pagingList = this.Model })
</nav>
<br />
@foreach (var item in Model)
{
<div class="col-lg-4 col-md-6 col-sm-6 product-men women_two">
<div class="product-toys-info">
<div class="men-pro-item">
<div class="men-thumb-item">
@if (item.Logo != null)
{
<img src=@Url.Content(item.Logo.Replace("//","/").Replace("///","/")) class="img-thumbnail img-fluid" alt="">
}
<div class="men-cart-pro">
<div class="inner-men-cart-pro">
<a href=@Url.Action("OrganizationInfo","Home",new { id=item.Id}) class="link-product-add-cart">View</a>
</div>
</div>
</div>
<div class="item-info-product">
<div class="info-product-price">
<div class="grid_meta">
<div class="product_price">
<h4>
<a href=@Url.Action("OrganizationInfo","Home",new { id=item.Id})>@item.Company</a>
</h4>
<p>@item.Moto</p>
</div>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
}
<br />
<nav aria-label="NewsFeeds navigation example">
<vc:pager paging-list="@Model" />
</nav>
</div>
</div>
Aucun commentaire:
Enregistrer un commentaire