I have a collection that I populate in the controller MenuitemDetails and this populates a property on the view model.
The collection has 3 properties and multiple records Id, Title and State
State is an integer value which relates to a dropdown list selected value.
The viewmodel also contains a selectList property (stateList) which is used to populate the dropdownlist items on the view.
I'm trying to repopulate the form for an edit action - with the same dropdown item selections
<table>
@for (int counter = 0; counter < Model.MenuitemDetails.Count; counter++)
{
<tr>
<td>
@Model.MenuitemDetails[counter].Title
@Html.DropDownListFor(i => Model.MenuitemDetails[counter].state, Model.stateList)
</td>
<hr />
</tr>
}
</table>
I can't seem to get the values of the dropdown to display the appropriate values selected.