I'd like to make a dropdown menu in a cshtml file using Razor. I'm using a ViewModel, in which I define a list. I'd like to use that list's values as dropdown options. For this, I'mtrying:
@Html.DropDownListFor(m => m.SelectedLocation, m => m.travellocations, "Select location!")
m => m.travellocations
travellocations = new List<SelectListItem>();
The second parameter is not a lambda expression, so use this declaration:
@Html.DropDownListFor(m => m.SelectedLocation, Model.travellocations, "Select location!")
The lambda expression "m" is a shortcut for Model anyway.