首页 > 代码库 > Html.DropDownList 选中 mvc view 弱类型

Html.DropDownList 选中 mvc view 弱类型

 List<Model.SysGroup> listGroup = sysGroupBll.Where(o => o.IsSb == true, o => o.Id).ToList();
            List<SelectListItem> items = new List<SelectListItem>();
            foreach (var group in listGroup)
            {
                items.Add(new SelectListItem { Text = group.Name, Value = http://www.mamicode.com/group.Id >            }
            this.ViewData["list"] = items;
            this.ViewData["GroupId"] = CurrentUser.SysGroup.FirstOrDefault().Id;

 

 

 <td>组 @Html.DropDownList("GroupId", ViewData["list"] as IEnumerable<SelectListItem>)</td>