I have to pass an (ID) parameter to the index of a controler,
I tried to use ActionLink
but it did not work.
View:
<body>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.Tag)
</th>
<th>
@Html.DisplayNameFor(model => model.Fluido)
</th>
<th>
@Html.DisplayNameFor(model => model.Vedacao)
</th>
<th>
@Html.DisplayNameFor(model => model.Criticidade)
</th>
<th>
@Html.DisplayNameFor(model => model.Mtbf)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<th>
@Html.DisplayFor(modelItem => item.Tag)
</th>
<td>
@Html.DisplayFor(modelItem => item.Fluido)
</td>
<td>
@Html.DisplayFor(modelItem => item.Vedacao)
</td>
<td>
@Html.DisplayFor(modelItem => item.Criticidade)
</td>
<td>
@Html.DisplayFor(modelItem => item.Mtbf)
</td>
<td>
@Html.ActionLink("Detalhes", "Index", "RelatorioRa", new { tagId = item.TagID })
</td>
</tr>
}
</table>
Control RelatorioRa
that will receive ID:
public async Task<ActionResult> Index(int? tagId)
{
var relatorioRaModels = db.RelatorioRaModels.Include(r => r.RelatorioTag);
if (tagId.HasValue)
{
//realiza o filtro para a tag selecionada
relatorioRaModels = relatorioRaModels.Where(a => a.TagID == tagId);
}
return View(await relatorioRaModels.ToListAsync());
}