MainView에 콤보 박스가 있으며이 콤보 박스에는 MainView에서 렌더링 할 PartialView를 반환하는 서버에 대한 AJAX 호출이 있습니다.Asp.Net 동적 바인딩 렌더링 된 부분 뷰
MAINVIEW 다음 VieModel 있습니다
public class CupomFiscalDetalhesViewModel
{
//Properties
public PlanoPagamentoViewModel PlanoPagamentoSelecionado { get; set; }
}
PartialView, 다음 뷰 모델이 있습니다을 :
인터페이스는이 경우에 내가 보여 줄게, 다른 두 ViewModels에 의해 구현 될 수
public class PlanoPagamentoViewModel
{
public int QuantidadeParcelas {get; set;}
public IPlanoPagamentosParcelas PlanoPagamentosParcelas { get; set; }
}
ViewModel은 다음을 구현합니다.
public class PlanoPagamentoCartaoViewModel : IPlanoPagamentosParcelas
{
public List<ParcelaViewModel> Parcelas { get; set; }
}
일단 사용자가 값을 콤보 박스, 동적으로 jQuery 아약스 부분 뷰 중 하나를 사용하여로드합니다.
나는 PartialView에 결합하기 위해 노력하고있어 방법의 예 :
모델이 나는 부분보기 속성의 중첩 된 속성에 바인딩 어떻게해야합니까PlanoPagamentoViewModel
의 유형이
@for (int i = 0; i < Model.QuantidadeParcelas; i++)
{
@Html.EditorFor(model => model.PlanoPagamentosParcelas.Parcelas[i].DataVencimento, new { htmlAttributes = new { @class = "form-control col-md-offset-4" } })
}
POST 동작에서 내 CupomFiscalDetalhesViewModel
?
.cshtml 페이지 상단에'@model Model_Name'에 대해 이야기하고 있습니까? –
어디에서이 QuantidadeParcelas를 얻었습니까? – pjobs
@pjobs, QuantidadeParcelas는 PlanoPagamentoViewModel (PartialView의 뷰 모델)에서 제공됩니다. – Maturano