Reputation: 53
My code is very simple and listed below:
I just want to pass id to the controller when I click on actionlink.
foreach (var item in Model)
{
<tr>
<td>@item.Name</td>
<td>@item.Cause</td>
<td>@Html.ActionLink("Edit","EditA","N",null,new {id=item.ActId})</td>
</tr>
}
With the above code currently the URL is generated like "N/EditA".
But I want the URL in this format "N/EditA/id". Any suggestions?
Upvotes: 0
Views: 443
Reputation: 3330
You can try the following
@Html.ActionLink("Edit","EditA","N",new {id=item.ActId})
Upvotes: 0
Reputation:
You using the overload incorrectly and adding the id
as a html attribute, not as a route value. It needs to be
@Html.ActionLink("Edit", "EditA", "N", new { id = item.ActId }, null)
Upvotes: 1