views:

17

answers:

1

I'm using an EditorFor()

<%: Html.EditorFor(model => model.documentInfo.destinations)%>

instead of a foreach

<% foreach (var item in Model.documentInfo.destinations)
   {
       Html.RenderPartial("Document/Destination", item);
   }
%>

Is it possible to get the numerical index of which item the EditorFor() is displaying?

Edit: I would like to use the index inside the editor template to generate custom incremental names/IDs for my fields in the template.

A: 

Try creating a strongly-type template of type IList.

<%@Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IList>" %>

<% for(int i = 0; i < Model.Count; i++) { %>
    <h1><%:Model[i]%></h1>
<% } %>
adriaanp