如何动态绑定(bind)数据到<%Html.Dropdownlist....
在 ASP.NET MVC 中?
最佳答案
只需将正确的 IEnumerable 作为类型化模型或 ViewData 传递。尝试这样的事情(在我脑海中):
<%= Html.DropDownList(string.Empty,
"myDropDownList",
new SelectList((IEnumerable)ViewData["stuff"],
"DescriptionProperty",
"ValueProperty"))
%>
使用 MVC 中的下拉列表助手,您不会像在旧 ASP.NET 中那样真正将数据“绑定(bind)”到它。
关于asp.net-mvc - 将数据动态绑定(bind)到asp.net mvc中的下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/214998/