Multiple addition in one view, ASP.NET MVC

I am trying to add multiple elements of the same type at the same time in the same view, providing a model.

@model List<Item>

For presentation, it displays, when I send the message back, the model is null, although the form data is sent correctly, but for some reason the display does not occur.

+4
source share
1 answer

For complex elements, you need to index your collections to bind to the model.

, ( Field ).

   @for (int i = 0; i < Model.Count; i++)
    {
        .....
        @Html.EditorFor(model => Model[i].Field)
        .....
    }

.

. :

http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx/

+2

All Articles