Adding a default SelectListItem

后端 未结 7 1205
一整个雨季
一整个雨季 2020-12-28 18:33
 public IEnumerable GetList(int? ID)
 {
      return from s in db.List
             orderby s.Descript
             select new SelectListItem
          


        
7条回答
  •  生来不讨喜
    2020-12-28 18:56

    return new[] { new SelectListItem { Text = ... } }.Concat(
           from s in db.List
           orderby s.Descript
           select new SelectListItem
           {
               Text = s.Descript,
               Value = s.ID.ToString(),
               Selected = (s.ID == ID)
           });
    

提交回复
热议问题