Reputation: 3
I'm working on a webgrid using mvc 3 razor and the paging simply does not work. there is paging but the link is just a '#'. I made another one in another project, which is exactly the same code and it works perfectly! The only difference between them is that the model layer on the project that doesn't work is a independent project, shared with another projects in the same solution. here goes the code:
Controller:
public ActionResult Index(int? page, string sortDir, string sort = "")
{
if (AuthRepository.hasUsuarioAutenticado)
{
List<CLIMA> list = new List<CLIMA>();
list = GetClimas(page, sortDir, sort);
return View("Index", list);
}
return RedirectToAction("Index", "Home");
}
public List<CLIMA> GetClimas(int? page, string sortDir, string sort)
{
var query = _rep.GetAll().OrderByDescending(p=>p.CLIMA_ID);
return query.ToList();
}
View:
WebGrid grid = new WebGrid(source: Model, canSort: false, canPage: true, ajaxUpdateContainerId: "grade", rowsPerPage: 20, ajaxUpdateCallback: "grade");
@grid.GetHtml(
tableStyle: "grade",
headerStyle: "header",
alternatingRowStyle: "alt",
columns: grid.Columns(
grid.Column("nome", header: "Cidade", format: @<text>@item.CIDADE_NOME</text>, canSort: false),
grid.Column("descricao", header: "Data", format: @<text> @item.OBSERVATION_TIME</text>, canSort: false),
grid.Column(header: "Ações", format: @<text> @Html.ActionLink("Editar", "Editar", new { id = item.CLIMA_ID })
@Html.ActionLink("Deletar", "Delete", new { id = item.CLIMA_ID }, new { @onclick = "return ConfirmaDelete();" })
@Html.ActionLink("Config. Clima", "Editar", "ClimaConfig", new { id = item.CLIMA_CONFIG }, null)
</text>)
there is paging but the link is just a '#'.
Upvotes: 0
Views: 2337
Reputation: 30045
You have specified an ajaxUpdateContainerId
. That means your paging is AJAX based - hence the # in the href. IF you want URLs, you need to remove the ajaxUpdateContainerId
.
Upvotes: 1