For some reason my drop down list is not retaining it's selected value - I know I am missing something simple here. Thanks for any comments!
Controllers
public ActionResult Test()
{
ViewData["MonitoringType"] = new SelectList(myModel.GetMonitoringType(), "Category", "Category");
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Test(FormCollection formValues)
{
ViewData["MonitoringType"] = new SelectList(myModel.GetMonitoringType(), "Category", "Category", formValues["MonitoringType"]);
return View();
}
And View:
This doesn't work
<%= Html.DropDownList("MonitoringType", (SelectList)ViewData["MonitoringType"],new {style = "width: 300px;"})%>
This works
<%= Html.DropDownList("MonitoringType")%>