I have my grid with the haged Pagedlist helper
<div class="table-responsive">
<table class="table table-hover">
<tr>
<th>
@Html.ActionLink("Id", "Index", new { OrderBy = ViewBag.OrdenaPorId, FiltroPagina = ViewBag.FiltroPagina })
</th>
<th>
@Html.ActionLink("Nome", "Index", new { OrderBy = ViewBag.OrdenaPorNome, FiltroPagina = ViewBag.FiltroPagina })
</th>
<th>
@Html.ActionLink("Descrição", "Index", new { OrderBy = ViewBag.OrdenaPorDescricao, FiltroPagina = ViewBag.FiltroPagina })
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Nome)
</td>
<td>
@Html.DisplayFor(modelItem => item.Descricao)
</td>
<td style="text-align:right;">
@Html.ActionLink("Editar", "Editar", new { id = item.Id }, new { @class = "btn btn-primary" })
<button class="btn btn-danger" onclick="deletar(@item.Id)">Deletar</button>
</td>
</tr>
}
</table>
</div>
<br />
Página @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) de @Model.PageCount
@Html.PagedListPager(Model, Pagina => Url.Action("Index", new { Pagina, Orderby = ViewBag.AtualOrder, FiltroPagina = ViewBag.FiltroPagina }))
When you click delete, it opens a modal, and it makes a post for the delete action
But here comes the problem,
If error occurs, you should return the error message, otherwise I need a "reload" on my grid
The error message, ok, but what about reload? how do I use PagedList?
$.ajax({
url: "Deletar",
type: "POST",
data: { Id: Id},
success: function (data) {
//Como faço o reload aqui?
},
error: function (data) {
//Mensagem de erro
}
});