1
I have a views that lists my users, is basically in the pattern generated by Asp.net mvc with Entity, the data is in a table, and within this table I have a :
@Html.ActionLink("Aprovar cadastro", "Aprovar")
And I have inside the controller Action:
[HttpGet]
public ActionResult Aprovar(int? Id)
{
if(Id == null){return new HttpStatusCodeResult(HttpStatusCode.BadRequest);}
else {
//A função será implementada aqui
}
}
Basically I need to pass the Id of a specific user to this controller, but I’m not succeeding.
Follow my view:
@model IEnumerable<ApegaPet.Models.ApplicationUser>
@{ Layout = "~/Views/Shared/_SideNavbar.cshtml"; }
@{
ViewBag.Title = "Avaliar_Ong";
}
<h2>Avaliar requisição de cadastro de Ongs</h2>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.nomerazao)
</th>
<th>
@Html.DisplayNameFor(model => model.endereco)
</th>
<th>
@Html.DisplayNameFor(model => model.telefone)
</th>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Email)
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.nomerazao)
</td>
<td>
@Html.DisplayFor(modelItem => item.endereco)
</td>
<td>
@Html.DisplayFor(modelItem => item.telefone)
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Email)
</td>
<td>
@Html.ActionLink("Aprovar cadastro", "Aprovar")
</td>
</tr>
}
</table>
For example, this.id item has to necessarily be displayed in the view ?
– Prostetnic Vogon Jeltz
No, @Prostetnicvogonjeltz can be a number chosen by its programming, just need to follow the same nomenclature of
new { Id =
where the value should be an integer. I put it like this because I imagined it would be him, but, it may be as already said of his programming.– novic
@Prostetnicvogonjeltz it is worth remembering that this Id is not mandatory, because its rule allows him to be
null
, looking out forcontroller
int? Id
!– novic