I can't figure out how to use model binding to update a child collection like I can in MVC. All the collection-type controls seem to assume some server-side storage mechanism using an edit/update lifecycle, which doesn't fit if this is supposed to be an insert form where I want to store the child collection in the form itself.
public class BarViewModel
{
public string Name {get;set;}
}
public class FooViewModel
{
public string Description {get;set;}
public List<BarViewModel> Bars {get;set;}
}
What can I use in the ??? section here:
<asp:FormView ID="Entry" RenderOuterTable="false" runat="server" DefaultMode="Insert"
ItemType="FooViewModel" SelectMethod="Entry_GetItem" InsertMethod="Entry_InsertItem">
<InsertItemTemplate>
<asp:TextBox ID="txtDescription" Text="<%# BindItem.Description %>" runat="server" />
<!-- ??? -->
</InsertItemTemplate>
</asp:FormView>
So that I can write an InsertMethod that executes TryUpdateModel, and the child collection populates with the values from ???
I've tried repeaters, gridviews and listviews, and none of them seem to work. This problem doesn't seem to have any answer online [1], but seems like it should be an obvious scenario, and is straightforward in MVC.
[1] ASP.NET Web Forms 4.5 model binding where the model contains a collection