这个问题主要是写代码习惯造成。
解决方案就是
将ViewData的名字与字段名字不能使用同一个。就能使用model默认显示了。
例子:
controller中的内容
ViewData["Category"] = items;
View中内容
@Html.DropDownListFor(model => model.ArticleCategory, ViewData["Category"] as IEnumerable<SelectListItem>, new { @class = "col-xs-10 col-sm-5" })
注意
ArticleCategory
和
ViewData["Category"]
这两个名字绝对不能一样,否则就会导致默认值不能显示。