I have a collection of objects on my Model that I\'m rendering in a View by using EditFor function, and I have an EditorTemplate which is responsible for actually rendering
There are some very good blog posts that allow you to modelbind to a list without the need to provide zero based contiguous index. plz have a look at
http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/
http://zahidadeel.blogspot.com/2011/05/master-detail-form-in-aspnet-mvc-3-ii.html
Furthermore, if you are interested in MVVM pattern and knockout js you can check this great work by steve sanderson
For more reading put "editing varibale length list mvc style" in google and it will give u a dozen useful links
Ran into this issue recently and solved it by converting the List to a Dictionary<string, model> with GUIDs as the key.
@foreach (var index in Model.EmailAddresses.Keys)
{
<label asp-for="@Model.EmailAddresses[index].Email">Email</label>
<input asp-for="@Model.EmailAddresses[index].Email" type="text" />
}
This avoided having to include hidden inputs that map to the index value.