I am trying to create a dropdown list that contains values from my data model. I cannot seem to get this to work inside of my view:
@Html.DropDownList("Program Types",
new SelectList(Model.Select(x => x.ProgramType.ProgramType).Distinct().OrderBy(x => x),
Model.Select(x => x.ProgramType.ProgramTypeId).Distinct().OrderBy(x => x)))
Take a look at this example:
How to write a simple Html.DropDownListFor()
It doesn’t get any simpler than that and you can adjust this example to your case quite easily.
Hope this is of help to you & good luck!