Asp.net mvc 在asp.net mvc中将数据动态绑定到dropdownlist

Asp.net mvc 在asp.net mvc中将数据动态绑定到dropdownlist,asp.net-mvc,data-binding,Asp.net Mvc,Data Binding,如何将数据动态绑定到只需传递正确的IEnumerable作为类型化模型或ViewData。试试这样的东西(从我脑子里): 使用MVC中的下拉列表帮助器,您实际上不会像在旧ASP.NET中那样将数据“绑定”到它。下面的链接提供了两种绑定下拉列表的方法。 绑定下拉列表 <%= Html.DropDownList(string.Empty, "myDropDownList", new SelectList((IEnumerable)ViewData["stuff"],

如何将数据动态绑定到
只需传递正确的IEnumerable作为类型化模型或ViewData。试试这样的东西(从我脑子里):


使用MVC中的下拉列表帮助器,您实际上不会像在旧ASP.NET中那样将数据“绑定”到它。

下面的链接提供了两种绑定下拉列表的方法。 绑定下拉列表

<%= Html.DropDownList(string.Empty, 
    "myDropDownList",  
    new SelectList((IEnumerable)ViewData["stuff"], 
        "DescriptionProperty", 
        "ValueProperty")) 
%>