I have a view that allows the user to inset multiple elements of the same type.
@foreach (var gm in Model)
{
-
For what it's worth you probably want.
It appears from the source code that the ExpressionHelper method used to translate the name from the model expression understands about array indexing expressions. You might try something like:
@for (int i = 0; i < Model.Count; ++i )
{
@Html.TextBoxFor(m => m[i].name)
}
I'll confess that I haven't tried this in MVC3 so I'm not sure whether it will work or not. In earlier versions I built this sort of thing by hand.
- 热议问题