Скажем, у меня есть следующее:
public class Person{
public int ID {get; set;}
public string Name {get; set;}
}
public class Phone{
public int ID {get; set;}
public string PhoneNumber {get; set;}
}
public Class AddEditViewModel{
public Person MyPerson{get; set;}
public List MyPhones{get; set;}
}
I want to create a create/edit action in my MVC app - the page inherits from
ViewPage<AddEditViewModel>and i want to be able to dynamically add the fields for the end-user to add a "phone" (anywhere between 0 - 5 phones). How would i pass that data to the Create/Edit method in my controller. I have tried the following, but nothing seems to get the phone numbers.
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(AddEditViewModel data){}
с этим я могу вызвать data.MyPerson.Name и получить значение, но data.MyPhones == null
Мой вопрос: как настроить представление и контроллер, чтобы иметь возможность отправлять одну страницу добавления / редактирования, которая создает объект одного человека с несколькими объектами телефона с учетом приведенного выше кода?