c# table 怎么在前台循环展示 ViewBag
后台
public ActionResult DoctorEvaluation()//前台页面 { HE_Department HE_dt = new HE_Department(); DataTable dt = HE_dt.GetDepartment();
//表转list 不知道怎么转请看 例子:http://www.cnblogs.com/LZXX/p/7763613.html List<Entitys.HE_Department> list = DataTableToList.ConvertTo<Entitys.HE_Department>(dt).ToList(); ViewBag.GetDepartmentList = list; //转化为LIST可以直接在前台循环 return View(); }
前台
@foreach (var list in ViewBag.GetDepartmentList) { <li>@list.DepartmentName</li> }
本文来自博客园,作者:12不懂3,转载请注明原文链接:https://www.cnblogs.com/LZXX/p/8862904.html