I create a site in MVC, and the View model that I pass to my View contains a custom object, which in turn contains a list of IEnumarable custom objects.
The idea is that the razor will dynamically generate a form for IEnumerable, which can be any number of objects.
@foreach (var data in Model.Kpi.Values) { <div class="editor-label"> @Html.Label(data.Field.Name); </div> <div class="editor-field"> @Html.EditorFor(model => data.Value) @Html.ValidationMessageFor(model => data.Value) </div> }
Forms render perfectly, including data annotations, however IEnumerable is null in the post controller function.
[HttpPost] public virtual ActionResult Create(KpiCreateViewModel vm) { return this.RedirectToAction(MVC.Kpi.Index()); }
I set a breakpoint on the return statement and checked the contents of the vm variable.
Can anyone suggest a method to get the form data?
Thanks in advance
source share