I have a asp .net mvc 3 web application. In one of its views I try to populate a couple of comboboxes. When I load the view, there doesn't appear to be a problem, until I try to read the data then I get the following 'The ViewData item that has the key 'GenderID' is of type 'System.Int32' but must be of type 'IEnumerable<SelectListItem>'
I've been populating the comboboxes using a method I have successfully used in other views, where it works like a charm, so I'm at a loss where I have my problem at the moment.
Here is how I fill the data in the controller:
var listGenders = ListGenders(); var dropDownGenders = new SelectList(listAgencies, "ID", "Name", 1);
ViewData["Genders"] = dropDownGenders;
In the view:
<div class="editor-label">
Gender
</div>
<div class="editor-field">
<%= Html.DropDownListFor(model => model.GenderID, ViewData["Genders"] as IEnumerable<SelectListItem>)%>
</div>
Does anyone here have an idea?