I\'m having trouble with this drop down box, just cant seem to get it right, here\'s the code:
View (Index.cshtml):
@using EvaSimulator.Models
@Model Eva
Use the For
helper instead to get compile time checking.
When using MultiSelectList
we need to bind the selected values to an array in the first param, then you can pass your select list with the values to be shown in the second param.
public string[] SelectedValues { get; set; }
public MultiSelectList DropDownList { get; set; }
Controller:
mv.DropDownList = new MultiSelectList(/*Your list of items here*/)
View:
@Html.DropDownListFor(x => Model.SelectedValues, Model.DropDownList)