I am really confused in ASP.Net MVC (2.0 RC) DropDownList. It does not seem to accept my selected item.
Here is my SelectListItem list (it is created inside a loop. Selected boolean)
savingTypesList.Add(new SelectListItem() { Selected = selected, Text = type.Name, Value = "" + type.SavingTypeId });
Creating the SelectList itself ..
return new SelectList(savingTypesList, "Value", "Text", (string)selected);
And my look ..
<p>
<label for="SavingType">Saving type</label>
<%= Html.DropDownList("SavingType", Model.SavingType, "-- select a parameter saving type --", "")%>
<%= Html.ValidationMessage("SavingType", "*")%>
</p>
When I check the details of the returned SelectList, it shows me the following information
alt text http://www.tx3.fi/selected.PNG
As you can see, SelectedValue is configured correctly and matches the item in the Items array. When I check the actual generated HTML, it is not selected. What's wrong?
source
share