ASP.Net MVC 베타 5를 사용하는 사이트가 있는데 방금 ASP.Net MVC 1.0으로 업그레이드했습니다. 드롭 다운 목록에서 선택한 항목에 문제가 있습니다.ASP.Net Html.DropDownList 선택한 요소가 선택되지 않았습니다.
추시 사람이 비슷한 질문 (Html.DropDownList in ASP.NET MVC RC (refresh) not pre-selecting item)을 가지고 있지만 나는 다음과 같이
내 컨트롤러 방법이 보인다 (이 버그 것보다 다른) 아무 대답이 없다 :
이[AcceptVerbs(HttpVerbs.Get)]
public ActionResult View(Guid id)
{
IntegrationLogic logic = new IntegrationLogic(new IntegrationLinq());
CompanyLogic companyLogic = new CompanyLogic(new CompanyLinq());
IntegrationContainer container = new IntegrationContainer();
container.Sources = logic.GetImportSource(id);
container.Companies = companyLogic.GetCompanies(); // Returns a IList<company>
container.SourceActions = logic.GetAllSourceActions(); // Returns an IList<SourceAction>
container.SinkActions = logic.GetAllSinkActions();
container.SuccessActions = logic.GetAllSuccessActions();
container.FailureActions = logic.GetAllFailureActions();
container.Actions = logic.GetAllActions();
container.Watchers = logic.GetAllWatcherActions();
container.ChainActions = logic.GetAllChainActions();
return View("View", container);
}
뷰입니다 다음과 같이 강하게 모델에 입력
public partial class View : ViewPage<IntegrationContainer> {}
뷰 템플릿의 문제 영역은 다음과 같습니다
,<label for="Companies">Company: </label><%=Html.DropDownList("Companies",
new SelectList(ViewData.Model.Companies, "id", "name", item.CompanyID))%>
드롭 다운 목록을 만들 때 선택한 항목이 실제로 선택되지 않습니다. 이것이 문제입니다. "item.CompanyID"는 Guid이고 "id"는 Guid이고 "name"은 ViewData.Model.Companies 인스턴스에있는 IList에 제공된 회사 개체의 문자열입니다.
이것은 실제로 버그입니까? - 이것이 ASP.Net MVC에 여전히 존재하는 이유를 이해하기 어렵습니다. 제가 한 일이라면 전적으로 행복 할 것입니다.
무엇을 제안 했습니까?
감사
여섯 가지 질문을 통해 검색 한 결과, 이것이 유일한 답 ... 감사합니다! – Martin
문제 없습니다. :) – Kinlan
이 벽에 내 머리를 두드리는 소리가났습니다. 고마워요. – aboy021