/// <summary> /// 获取用户信息 /// </summary> /// <returns></returns> public ActionResult GetUser() { //List<SelectListItem> list = new List<SelectListItem>() //{ // new SelectListItem() {Text="A11",Value="001"}, // new SelectListItem() {Text="A12",Value="002"}, // new SelectListItem() {Text="A13",Value="003"} //}; List <string> list = new List <string>(); Users selectUser = new Users(); string str = this.HttpContext.Request.Url.ToString(); try { UserDbContext uc = new UserDbContext("ConnStr1"); List <Users> uList = uc.GetUsersByName(string.Empty, true); List <SelectListItem> userList = new List <SelectListItem>(); for (int i = 0; i < uList.Count; i++) { SelectListItem item = new SelectListItem(); item.Text = uList[i].UserName; item.Value = uList[i].UserID; userList.Add(item); } this.ViewData["USERLIST"] = userList; } catch (Exception ex) { if (ex.Message != null) { } this.ViewBag.ErrMsg = MisBase.BaseUT.GetRootException(ex).Message; } return(View(selectUser)); }
/// <summary> /// 获取用户列表 /// </summary> /// <returns></returns> public JsonResult GetUserDataGrid() { UserDbContext udb = new UserDbContext("ConnStr1"); List <Users> list = udb.GetUsersByName(string.Empty, true); var list2 = from r in list select new { UserAccount = r.UserAccount, UserCertNo = r.UserCertNo, UserCertType = r.UserCertType, UserID = r.UserID, UserID2 = r.UserID, UserName = r.UserName, UserPhone = r.UserPhone, UserUnit = r.UserUnit }; return(Json(list2.ToList(), JsonRequestBehavior.AllowGet)); }