Paged ASP.NET MVC PagedListPager with more than one parameter

1

I have the following page using x.PagedList

@using AspNet.Models;
@using X.PagedList.Mvc

@{

ViewBag.Title = "Visualiza";
@model X.PagedList.IPagedList<AspNet.Models.Pessoa>

}

<h2>Pessoas Cadastradas</h2>
<div class="table-responsive">
<table class="table table-bordered table-hover table-inverse">
    <thead>
        <tr>
            <th>Nome</th>
            <th>Idade</th>
            <th>Usuario</th>
            <th>Setor</th>
            <th>Sub Setor</th>
            <th>Editar</th>
        </tr>
    </thead>
    <tbody>
        @foreach (Pessoa pessoa in Model)
        {
            <tr>
                <td>@pessoa.nome</td>
                <td>@pessoa.idade</td>
                <td>@pessoa.usuario</td>
                <td>@pessoa.setor</td>
                <td>@pessoa.sub_setor</td>
                <td>@Html.ActionLink("Editar", "Edita", "Pessoa", new { 
 @id_pessoa = pessoa.id_pessoa }, null)</td>
            </tr>
        }
    </tbody>
  </table>
 </div>
  Página @Model.PageNumber de @Model.PageCount
  @Html.PagedListPager(Model, page => Url.Action("Visualiza","Pessoa", new 
  {pagina = page}) + "&setor=" + ViewBag.setor)

Note that in the URL.Action above I am passing two GET parameters, the page and the sector ... when the page is generated, it correctly generates the get link:

However,whenIgotopage2andwanttogobackto1,itlosesthegetsector:

Can anyone help me with this?

    
asked by anonymous 10.08.2018 / 04:08

1 answer

0

I've been able to do it. I was specifying the Action wrong. The correct would be:

@Html.PagedListPager(Model, page => Url.Action("VisualizaPorSetor","Pessoa", new {pagina = page}) + "&setor=" + ViewBag.setor)
    
14.08.2018 / 18:21