I have property in my model which is a collection type (List). I'd like to call for each item in this collection Html.DisplayFor
or Html.EditorFor
. How can I do this ?
EDIT It's not a strong-typed view. It's a templated view. There is only ViewData.ModelMetadata.
Can you try
<% foreach (var item in Model.MyCollection) { %>
<%= html.EditorFor(m=>item) %>
<% } %>
Something like this, in your view?
<% foreach (var item in Model.MyCollection) { %>
<%= html.EditorFor... %>
...
<% } %>
See also using Html.EditorFor with an IEnumerable<T>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With