I want to dynamically create several panel sections that each contain a partial view and have each bind to a corresponding model.
I have a main model that contains a list of child models. Each child model has a property to specify the name of it's partial view.
The logic below correctly outputs each panel's content by using a foreach statement.
The issue I'm having is the "for each" loses my child models when I post my main model back to the controller on save.
How can I perform the same logic utilizing a "BindTo" instead of a "foreach"?
Are their any other ways to dynamically create panel bars containing partial views via a model collection?
@(Html.Kendo().PanelBar()
.Name("panelbar")
.ExpandMode(PanelBarExpandMode.Multiple)
.Animation(animation => animation.Enable(false))
.Items(panelbar =>
{
foreach (ModelBase childModel in Model.ChildModels)
{
panelbar.Add()
.Text(childModel.PartialViewTitle)
.Content(@<section>
@Html.Partial(childModel.PartialViewName, childModel)
</section>);
}
}));
I have a main model that contains a list of child models. Each child model has a property to specify the name of it's partial view.
The logic below correctly outputs each panel's content by using a foreach statement.
The issue I'm having is the "for each" loses my child models when I post my main model back to the controller on save.
How can I perform the same logic utilizing a "BindTo" instead of a "foreach"?
Are their any other ways to dynamically create panel bars containing partial views via a model collection?
@(Html.Kendo().PanelBar()
.Name("panelbar")
.ExpandMode(PanelBarExpandMode.Multiple)
.Animation(animation => animation.Enable(false))
.Items(panelbar =>
{
foreach (ModelBase childModel in Model.ChildModels)
{
panelbar.Add()
.Text(childModel.PartialViewTitle)
.Content(@<section>
@Html.Partial(childModel.PartialViewName, childModel)
</section>);
}
}));