I am calling Edit action from my view that should accept an object as parameter.
Action:
[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(); } } From 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> }
It is raising an exception: The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Edit(Int32)' in 'PartyWeb.Controllers.Internal.OrganizationController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters
Can somebody advise how to pass object as parameter?