1
에서 SelectedValue를 설정하는 캐스팅?엔티티에 LINQ와 문제 및 값 형식 '부울'나는 코드 아래에 다음과 같은 selectedValue와 드롭 다운리스트를 만들 SelectListItem
감사합니다.
에서 SelectedValue를 설정하는 캐스팅?엔티티에 LINQ와 문제 및 값 형식 '부울'나는 코드 아래에 다음과 같은 selectedValue와 드롭 다운리스트를 만들 SelectListItem
감사합니다.
이 시도 : (당신이이 nullable 형식이기 때문에 허용하는) 당신이 컨트롤러에 널 섹션 ID에 전달하면 반환 그래서, 그것은 아마도 당신의 엔티티의 ID와 일치 할 수
public static IEnumerable<SelectListItem> GenSectionList(int? sectionId)
{
SectionRepository sectionRep = new SectionRepository();
var sections = sectionRep.GetAllSections();
int i = sections.ToList().Count();
return sections.Select(s => new SelectListItem()
{
Text = s.Title,
Value = SqlFunctions.StringConvert((double)s.Id),
Selected = sectionId.HasValue ? s.Id == sectionId.Value : false
});
}
이 경우 거짓 ...