All, I am trying to edit the data using MVC4.
When I click on Edit link - I could see the param name AND Value getting appended in the querystring but in controller I am unable to get the value for selected row
Controller Code
public ActionResult Edit(string id)
{
PhonebookModel PHm = _phList.Find(x => x.ID == id);
return View(PHm);
}
Here in controller, I am getting ID as null.. Any clue what I am doing wrong?
Note: I can see the Edit screen but all controls are empty.
Thanks in advance. cshtml code that generates Edit link @model IEnumerable
@{ ViewBag.Title = "Index"; }
Index
@Html.ActionLink("Create New", "Create")
@Html.DisplayNameFor(model => model.FirstName) @Html.DisplayNameFor(model => model.Last Name) @foreach (var item in Model) { @Html.DisplayFor(modelItem => item.FirstName) @Html.DisplayFor(modelItem => item.LastName) @Html.ActionLink("Edit", "Edit", new { ID = item.ID}) | @Html.ActionLink("Details", "Details", new { ID = item.ID }) }
Edit
action? – Simon C