MVC筛选自定义属性下拉表
MVC筛选自定义属性下拉表
string CompanyId = ""; CompanyId = ManageProvider.Provider.Current().CompanyId; //下拉菜单 var classinfoList = classinfobll.GetList(CompanyId).Where(a => a.FlagGraduate == true).Select(c => new { id = c.Id, classCode = c.ClassCode, textField = c.CurrentGradeName + c.CurrentClassName + c.ClassCode }).OrderBy(o => o.classCode).ToList(); //将数据封装到 SelectList中,制定要生成下拉框选项的value和text属性 SelectList cList = new SelectList(classinfoList, "id", "textField"); ViewBag.cList = cList.AsEnumerable();
效果图: