I want to select a WebGrid line through a RadioButton and click the Preview button, / em> with the selected line information.
How do I pass information from the selected line to controller
?
CSHTML:
@model IEnumerable<WebAppEight.Models.ContratosUnidade>
<link href="~/Content/Perfil/webgrid-style.css" rel="stylesheet" />
<link href="~/Content/Perfil/perfil-style.css" rel="stylesheet" />
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
WebGrid grid = new WebGrid(Model, rowsPerPage: 6);
}
@using (Html.BeginForm("ContratoSelecionado", "Contratos", FormMethod.Post))
{
@Html.AntiForgeryToken()
@grid.GetHtml(
tableStyle: "webgrid-table",
headerStyle: "webgrid-header",
footerStyle: "webgrid-footer",
alternatingRowStyle: "webgrid-alternating-row",
rowStyle: "webgrid-row-style",
fillEmptyRows: true,
mode: WebGridPagerModes.All,
columns: new[]
{
grid.Column(format:@<text><input type="radio"
id="contratosUnidade"
name="contratosUnidade"
checked="@item.Codigo" /></text>,
style: "webgrid-select-column"),
grid.Column("Codigo", "Código"),
grid.Column("FormaContratacao", "Forma de Contratação")
}
)
<div class="ddldiv">
<input class="input-buttons-footer" type="submit" value="Visualizar" />
<input class="input-buttons-footer" type="submit" value="Editar" />
<input class="input-buttons-footer" type="submit" value="Novo" />
<input class="input-buttons-footer" type="submit" value="<" />
</div>
}
Controller (which should receive some information from the selected line):
public ActionResult ContratoSelecionado(string codigo)
{
return View();
}
Obs: The controller ContratoSelecionado
is called, however, without parameters.