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;
そして、私の見解では、私が持っている:
<%= Html.DropDownList("categories")%>
をしかし、私はエラーがあります:キー「カテゴリ」を持っているのViewData項目があります'[Category、MvcApplication1、Version = 1.0.0.0、Culture =ニュートラル、PublicKeyToken = null]' '型の' System.Collections.Generic.List 'タイプですが、' IEnumerable 'タイプである必要があります。
Uggggghhh解決方法
私のチュートリアルはこれを説明するモデルの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/archive/2012/01/09/cascasding-dropdownlist-in-asp-net-mvc.aspx – RickAndMSFT