后台无论用viewbag或是viewdata都不是重点,前台无论用@Html.DropDownList @Html.DropDownListFor都无所谓
重点是当后台用ViewData["typeBtnList"]=..... 或者ViewBag.typeBtnList =......前台用
@Html.DropDownList("typeBtnList", ViewData["typeBtnList"] as List
@Html.DropDownList("typeBtnList", ViewBag.typeBtnList as List
而当我们把前台改成
@Html.DropDownList("aaaaa", ViewData["typeBtnList"] as List
@Html.DropDownList("aaaaa", ViewBag.typeBtnList as List
结论:
参数命名很重要,因为看不到源码,故猜测问题便是名称问题
查看更多关于关于mvc中@Html.DropDownListFor和@Html.DropDownList默认值无的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did110566