I have made table with Actionlink. Actionlink open new View and as parametr to Action I want to send @item - full object. How can I make it?
Model:
public class MyClass
{
//I have properties here.
}
Controller:
public class MyController : Controller
{
public ActionResult ActionName(MyClass tm)
{
//have a breakpoint here
return View();
}
}
View:
<table>
<tr>
<th> Column title one </th>
<th> Column title two </th>
<th> Column title three </th>
</tr>
@foreach (var item in @Model)
{
<tr>
<td> @item.PropertyOne </td>
<td> @item.PropertyTwo </td>
<td> @item.PropertyThree </td>
@if (ViewData["smth"] == "true")
{
<td> @Html.ActionLink("Edit", "ActionName", "My", new { tm = @item }, null) </td>
}
</tr>
}
</table>
I need to say, that everything works fine, only after click to ActionLink, in MyClass tm is saved "null". Not the @item. How can I send it to Action if I don't want write "param1 = @item.propertyOne, param2 = @item.propertyTwo" etc.?
Thank you.