1.控制器中取得数据,构建SelectList,利用ViewData传值到View
//*****************得到所有部门名称*********//
List<string> names = dep_m_BLL.GetAllNames();
//*****************构建SelectList*********//
SelectList name = new SelectList(names);
ViewData["names"] = name;
return View();
2.在View中添加如下编码:
<%: Html.DropDownListFor(model => model.Inv_PP_Dep,(SelectList)ViewData["names"] ) %>
时间: 2024-10-19 08:21:14