/// <summary> /// 添加 /// </summary> /// <returns></returns> public ActionResult Create() { //两种不同类型list的转换 new SelectListItem()是实例化一个新对象 ViewBag.Rolename = User_dal.Roleslist().Select(r => new SelectListItem() { Text = r.Rolename, Value = r.Roleid.ToString() } ).ToList(); return(View()); }
/// <summary> /// 传值 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Update(int id) { Login_Info match = User_dal.details(id); ViewBag.Rolename = User_dal.Roleslist().Select(r => new SelectListItem() { Text = r.Rolename, Value = r.Roleid.ToString() } ).ToList(); return(View(match)); }