MVC3 ModelBinding to a collection posted back with index gaps

前端 未结 2 1980
情话喂你
情话喂你 2021-01-13 03:26

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

2条回答
  •  灰色年华
    2021-01-13 04:18

    Ran into this issue recently and solved it by converting the List to a Dictionary with GUIDs as the key.

    @foreach (var index in Model.EmailAddresses.Keys)
    {
        
        
    }
    

    This avoided having to include hidden inputs that map to the index value.

提交回复
热议问题