public ActionResult Register() { SelectList sl = new SelectList(_iStationEntityRepos.GetAllTeams(), "TeamEntityId", "TeamName"); ViewBag.sl = sl; return(View()); }
/// <summary> /// 获取team生成selectlist /// </summary> private void GetTeamValueAndSetViewBag() { var allTeams = _iStationEntityRepos.GetAllTeams(); SelectList sl = new SelectList(allTeams, "TeamEntityId", "TeamName"); ViewBag.sl = sl; }
private List <SelectListItem> GetSelectListItems() { var re = _iStationEntityRepos.GetAllTeams(); var result = (from teamEntity in re from stationEntity in teamEntity.StationEntities select new SelectListItem() { Group = new SelectListGroup() { Name = teamEntity.TeamName }, Text = stationEntity.StationName, Value = stationEntity.StationId.ToString() }).ToList(); return(result); }