オブジェクトをパラメーターとして受け入れるビューから編集アクションを呼び出しています。
アクション:
[HttpPost]
public ActionResult Edit(Organization obj)
{
//remove the lock since it is not required for inserts
if (ModelState.IsValid)
{
OrganizationRepo.Update(obj);
UnitOfWork.Save();
LockSvc.Unlock(obj);
return RedirectToAction("List");
}
else
{
return View();
}
}
ビューから:
@foreach (var item in Model) {
cap = item.GetValForProp<string>("Caption");
nameinuse = item.GetValForProp<string>("NameInUse");
desc = item.GetValForProp<string>("Description");
<tr>
<td class="txt">
<input type="text" name="Caption" class="txt" value="@cap"/>
</td>
<td>
<input type="text" name="NameInUse" class="txt" value="@nameinuse"/>
</td>
<td>
<input type="text" name="Description" class="txt" value="@desc"/>
</td>
<td>
@Html.ActionLink("Edit", "Edit", "Organization", new { obj = item as Organization }, null)
</td>
</tr>
}
例外が発生しています: パラメーター ディクショナリには、'PartyWeb.Controllers.Internal のメソッド 'System.Web.Mvc.ActionResult Edit(Int32)' の null 非許容型 'System.Int32' のパラメーター 'id' の null エントリが含まれています.OrganizationController'. オプションのパラメーターは、参照型または null 許容型であるか、オプションのパラメーターとして宣言する必要があります。パラメータ名: パラメータ
オブジェクトをパラメータとして渡す方法を教えてもらえますか?