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();

效果图:

posted @ 2016-07-20 14:52  代码沉思者  阅读(453)  评论(0编辑  收藏  举报