Editor Templates rendering multiple times (using Jquery)

142 Views Asked by At
public class PersonViewModel
{
 Public string PersonName{get; set;}
 Public string NumberOfCars{get;set;} // DropDown
}
Public Class CarViewModel
{
 Public string CareMake{get; set;}
Public string  Year{get; set;}
}

On a Page I have to display PersonViewModel related controls. Based on Number Of Cars selected( 2 or 3) I should be showing Input fields for CarViewModel (Which is an Editor Template)

Problem: I have written Editor Template for CarViewModel. Not sure how to call it dynamically based on drop down selected (i.e., NumberOfCars selected by person).

PS

  • I can Create Partial views and render multiple times dynamically based on dropdown selection. But not sure How to model bind child(CarViewModel) to Parent ViewModel which is PersonViewModel in case.
  • I haven't written all code for easy understanding of problem.
0

There are 0 best solutions below