I’m creating a drop down via
<%= Html.DropDownList("data.Language", Model.LanguageOptions) %>
and want to read back its value through automatic model binding into my LanguageModel viewmodel:
public ActionResult Save(LanguageModel data)
However, data.Language is null when the Save method is called.
How do I get the selected value from my data.Language dropdown into data.Language?
I don’t know how your controller action and model look like but this definitely works:
Model:
Controller:
View:
Of course if you are using ASP.NET MVC 2.0, the strongly typed
DropDownListForhelper is preferable.