Reputation:
I can only get the selected value to be selected on an MVC view when I use the ViewData object. If I try to bind directly to a property on my model which returns an Ienumerable it won't render the Selected tag into the html.
I am at a loss on this one.
Note: I do pass a strongly typed value to the View so my orginal binding was Model.Statuses where statuses is a property on my strongly typed model.
Upvotes: 1
Views: 232
Reputation: 18877
In your template you are probably doing something like this:
<%= Html.DropDownList("htmlName", Model.SomeIEnumerable) %>
And you need to make it a SelectList sort of like:
<%= Html.DropDownList("htmlName", new SelectList(Model.SomeIEnumerable, "valueProperty", "textProperty")) %>
Upvotes: 0