Reputation: 14511
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)))
Upvotes: 1
Views: 20770
Reputation: 4732
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!
Upvotes: 2