How to create a dynamic number of possibly children objects using partial views?
Posted
by
NullReference
on Stack Overflow
See other posts from Stack Overflow
or by NullReference
Published on 2012-04-14T21:03:12Z
Indexed on
2012/04/15
23:29 UTC
Read the original article
Hit count: 174
asp.net-mvc-3
I have a parent object that contains a property that is a list of children objects. I'd like to have it so that when the form loads to create the parent object a partial view is used to create the list of child objects.
The problem is I have to idea how to have the list of children object populated. I can do one object ok, but a dynamic list of possible children is difficult. Any ideas?
@Html.RenderPartial("_CreateChild", Model.Children);
public class Parent
{
private List<Child> _list;
public Guid Id
{
get;
set;
}
public List<Child> Children
{
get
{
return _list;
}
set
{
_list = value;
}
}
public Parent()
{
_list = new List<Child>();
}
}
© Stack Overflow or respective owner