In meinem Controller habe ich:Dropdownlist und Viewdata
Category x = new Category(1, "one", 0);
Category y = new Category(2, "two", 1);
Category z = new Category(3, "three", 1);
List<Category> categories = new List<Category>();
categories.Add(x);
categories.Add(y);
categories.Add(z);
ViewData["categories"] = categories;
Und meiner Meinung nach habe ich:
<%= Html.DropDownList("categories")%>
Aber ich habe einen Fehler: Der Viewdata Element, das die wichtigsten ‚Kategorien‘ hat, ist vom Typ 'System.Collections.Generic.List`1 [[Kategorie, MvcApplication1, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null]]', muss aber vom Typ 'IEnumerable' sein.
Uggggghhh, wie das zu lösen?
Meine Tutorials dies erklären http : //www.asp.net/mvc/tutorials/javascript/working-with-the-dropdownlist-box-and-jquery/using-the-dropdownlist-helper-with-aspnet-mvc http: //blogs.msdn .com/b/rickandy/archiv/2012/01/09/cascassing-dropdownlist-in-asp-net-mvc.aspx – RickAndMSFT