Is a List enumerable?
Html.List("mylistbox", Model.UserList);
doesnt' seem to be working, where UserList is a List collection.
Is a List enumerable?
Html.List("mylistbox", Model.UserList);
doesnt' seem to be working, where UserList is a List collection.
Are you using the DropDownList helper?
<%= Html.DropDownList("Layers", Model.GetLayersOptions("2"))%>
Make sure your Model.UserList property is of type IEnumerable<T>
. Here's my implementation:
public virtual IEnumerable<SelectListItem> GetLayersOptions(string defaultSt)
{
var items = new List<SelectListItem>
{
new SelectListItem() {Text = "1", Value = "1"},
new SelectListItem() {Text = "2", Value = "2"},
new SelectListItem() {Text = "12", Value = "12"}
};
Utils.SetSelectedItem(items, defaultSt, () => Layers);
return items;
}