Reputation: 47733
I'm trying to pass in an array to this dropdownlist in my Partial View:
<%
Html.DropDownList(Model.Name, Model.Options);
%>
The options are comma separated of course. It's expecting an IEnumerable so not sure what I'm missing here. It's not accepting the array.
Upvotes: 0
Views: 943
Reputation: 15350
Maybe you could show us more of your code such as the value of Model.Options but here is some code that may help.
model.Options = new SelectList(values.ToList(), "Key", "Value");
<%= Html.DropDownList(Model.Name,
(IEnumerable<SelectListItem>)model.Options) %>
Upvotes: 1
Reputation: 879
You can try this:
<%
Html.DropDownList(Model.Name, new SelectList(Model.Options));
%>
Upvotes: 0