How do I do the following?
I have a classic view with tables created with razor as follows:
...
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.a)
</td>
<td>
@Html.DisplayFor(modelItem => item.b)
</td>
<td>
@Html.DisplayFor(modelItem => item.c)
</td>
<td>
@Html.DisplayFor(modelItem => item.d)
</td>
<td>
@Html.DisplayFor(modelItem => item.e)
</td>
<td>
@Html.DisplayFor(modelItem => item.f)
</td>
<td>
@Html.DisplayFor(modelItem => item.g)
</td>
<td>
@Html.DisplayFor(modelItem => item.h)
</td>
<td>
@Html.DisplayFor(modelItem => item.i)
</td>
<td>
@Html.ActionLink("Listados", "listar", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}
....
Clearly it is a grid, that for each record has 3 links, the first one that has the name of Listing goes to the action to list, now, the question of the million is:
When I click on List, how do I pass the selected entity to the list action? and also how do I pass the value of one of the columns to the action list? obviously I also need to know how I recover the value in the stock. Preferably that this data does not pass through the URL.
Controller action:
public ActionResult listar(string dato)
{
CTPP oTar = new CTPP ();
oTar.strCodEmpresa = "1";
oTar.strNroTarjeta = dato;
oTar.datFechaIni = DateTime.Parse("01/01/2016");
oTar.datFechaFin = DateTime.Parse("12/12/2016");
CLIS oLis = Servicioweb.listar(oTar);
return View(oLis.lista);
}
Or else something more key would be, in the same scenario of the grid and the links, how did a data of the grid as a parameter to a controller action through POST?