We have a list of action links
Partial View
@foreach (var item in Model.Regions) { <tr> <td> @Html.DisplayFor(modelItem => item.RegionName) </td> <td> <input type="submit" value="Select" /> </td> @Html.HiddenFor(modelItem => Model.Id) </tr> } </table> I assume that this isn't the correct way to do this, but if you could point me in the right direction it would be appreciated. I want to submit this data into an existing form
Region View
@using (Html.BeginForm()){ <fieldset> @Html.Partial("_RegionsPartial"); <legend>Create new region</legend> <ol> <li>@Html.LabelFor(m => m.RegionName)</li> <li>@Html.EditorFor(m => m.RegionName)</li> </ol> <input type="submit" value="Next" /> @Html.HiddenFor(model => model.RegionId) </fieldset> } So you can either submit a new one or submit an existing one. Im not sure how to get the id of an existing one into my model. Here is the controller:
public ActionResult Region() { var model = new WizardModel(); var getRegions = _facade.FetchRegion(); model.Regions = getRegions; return View(model); } [HttpPost] public ActionResult Region(WizardModel model) { if (model.RegionName != null) { var newRegion = _facade.CreateRegion(model.RegionName); model.RegionId = newRegion.Id; } else { model.RegionName = _facade.FetchRegion(model.RegionId).RegionName; } TempData["suburbModel"] = model; return RedirectToAction("Suburb"); } Thanks for taking the time
model.RegionName = _facade.FetchRegion(model.RegionId).RegionName;this line is not working?