2010-11-29 3 views

답변

4

이 시도 : (당신이이 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  
    }); 
} 

이 경우 거짓 ...

관련 문제