Reputation: 113
So basically as the title said, currently working on a MVC5, how can I get the Id of the list of Items that I have in view of the controller? By a button click, I'm calling an action which doesn't have a view but requires the Id of the item, which is resulting in a NULL.
I read this article but they don't seem to work for me:
How to get the current user in ASP.NET MVC
public ActionResult GetItem(int Id)
{
Item item = new Repository().GetId(Id);
..
}
Upvotes: 0
Views: 673
Reputation: 8302
Okay, so after a discussion on the requirement, the following changes were required to be made on the View
:
<div class="col-lg-4">
<a href="@Url.Action("GetItem", "Upload", new { id = Model.id}"">
</a>
<P>@p.Path</P>
</div>
And the Controller:
public ActionResult GetItem(int id)
The URL
for each item would be generated uniquely based on the Model.id
Upvotes: 1