I'm trying to post back a form with an enumerable number of items. When I have a list of elements with name = item[0].StartDate
, name = item[1].StartDate
, name = item[3].StartDate
, etc. everything binds fine to an IEnumerable<Item> items
property. However, let's say the user removes the first element or the middle element, then the binding no longer works because the items element is null in the former case and only the first item binds in the latter case.
Would I have to rename all the name attributes in the DOM if I'm deleting an element? Or is there a behind the scenes way I can tell ASP MVC to create the items object and start binding anything with the pattern item[i].StartDate?