1
I want to select a line from Webgrid through a Radiobutton and by clicking the button Visualise, carry a partial view with the information of the selected line.
How do I pass the information from the selected line to the 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.
Adjust code formatting for better understanding.
– Murillo Goulart
I didn’t know I needed to format. I thought it was automatic.
– Anderson Machado