dropdownlist 값은 SelectList에서 설정되지 않음 ViewData에서 View로 전달되었습니다.
-
03-07-2019 - |
문제
페이지를 표시 한 후 브라우저에서 내 페이지 소스를 볼 때 사무실 위치 (텍스트) 및 주소 (값)의 드롭 다운 목록을 채우려고 노력하고 있습니다. 여기 내 코드가 있습니다. LinqToSQL 데이터 컨텍스트 호출을 사용하여 SelectList에 대한 데이터를 얻습니다. 디버거에서 전화에서 반환 된 목록에 실제로 필요한 주소와 사무실 위치가 있음을 알 수 있습니다. 내 모델 DataContext 코드 :
public partial class uls_dbDataContext
{
public List<office_location> GetOfficeLocations()
{
return office_locations.ToList();
}
}
내 컨트롤러 코드 :
public ActionResult Directions()
{
uls_dbDataContext ulsdb_dc = new uls_dbDataContext();
ViewData["OfficeLocations"] = new SelectList(ulsdb_dc.GetOfficeLocations(),"location_address", "location_name");
ViewData["Title"] = "Directions";
return View();
}
내보기 코드 : <%= html.dropdownlist ( "위치", (selectlist) ViewData [ "Officelocations"]%>
해결책
미리보기 4에서 MVC RC2로 업그레이드해야했습니다. DrodownList 문제를 해결하고 문제를 해결했습니다.
제휴하지 않습니다 StackOverflow