I want to use Html.DropDownList (string name, IEnumerable SelectList, Object htmlAttributes) to display a select list with a pre-selected value for me.
My picklist is in the model object of my view, so I wrote the following code:
<%= Html.DropDownList("aName", mySelectList, new { }) %>
A selection list will be displayed without a pre-selected value.
The workaround I found is to pass the SelectList as ViewData and do the following:
In the controller:
ViewData["TimeZones"] = mySelectList;
In view:
<%= Html.DropDownList("TimeZones", null, new { }) %>
This way the selection list will be displayed with a preselected value, however I do not want me to have to pass my selection list as presentation data. What am I doing wrong? Thanks in advance for your help.