这是我的控制器的一部分:
// GET
public ActionResult Create()
{
var query = from f in db.Stages
select f;
var sItems = new SelectList(query, "ID", "Name");
ViewBag.StagesList = sItems;
return View();
}
这是我的观点:
<div class="editor-field">
<%: Html.DropDownListFor(model => model.Name, ViewBag.StagesList as SelectList)%>
<%: Html.ValidationMessageFor(model => model.Name) %>
</div>
但是下拉列表没有出现在视图中。为什么?问题是什么?