控制器
DepartmentLevel departmentlevel = new DepartmentLevel();
ViewBag.DepartmentLevel =
new SelectList(db.DepartmentLevels, "DepartmentLevelId", "DepartmentLevelDesc",
departmentlevel.DepartmentLevelId).OrderBy(a => a.Text);
HTML
@Html.DropDownList("DepartmentLevel", ViewData["DepartmentLevel"] as SelectList,
"All Department", new { @style = "width:200px;" })
有什么问题?。
答案 0 :(得分:4)
您在$(ProjectDir)$(ProjectFileName) /t:Publish /p:xxxPackageSource=\\tfs2012\Repository
中使用了ViewBag
而不是ViewData
。因此,您应该在Controller
中使用ViewBag
,如下所示:
View