Actionlinkでテーブルを作成しました。Actionlink が新しいビューを開き、Action のパラメータとして @item - 完全なオブジェクトを送信したい。どうすれば作れますか?
モデル:
public class MyClass
{
//I have properties here.
}
コントローラ:
public class MyController : Controller
{
public ActionResult ActionName(MyClass tm)
{
//have a breakpoint here
return 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>
私は、MyClass tm で ActionLink をクリックした後にのみ、すべてが正常に機能することを言う必要があります。@アイテムではありません。「param1 = @item.propertyOne、param2 = @item.propertyTwo」などを書きたくない場合、どのようにアクションに送信できますか?
ありがとうございました。