I have the following code and when I update, I get the correct results out of a list of dropdowns. I.E.. if I update one of the list items to "Closed" it does exactly what it is told both in the view and the database.
But as soon as I move away from the view and then come back, I lose the "state". Is there a way I can add a "Selected" to this of do I need to re-think?
@{
var listItems = new List<ListItem> {
new ListItem {Text = "Open", Value = "Open"},
new ListItem {Text = "Closed", Value = "Closed"},
new ListItem {Text = "Standby", Value = "Standby"}};
}
@Html.DropDownList("Parks[" + (@i + 10) + "].ParkStatus", new SelectList(listItems), new { @class = "form-control" })
Edit
I think I need some kind of "Is Selected" in the following string?
@Html.DropDownList("Parks[" + (@i + 10) + "].ParkStatus", new SelectList(listItems), new { @class = "form-control" })