Asp.net mvc 2 在集合上使用EditorFor()时,是否可以返回当前迭代的索引?

Asp.net mvc 2 在集合上使用EditorFor()时,是否可以返回当前迭代的索引?,asp.net-mvc-2,Asp.net Mvc 2,我正在使用一个EditorFor() model.documentInfo.destinations)%%> 而不是一个foreach <% foreach (var item in Model.documentInfo.destinations) { Html.RenderPartial("Document/Destination", item); } %> 是否可以获取EditorFor()显示的项目的数字索引 编辑:我想使用编辑器模板内的索引为

我正在使用一个EditorFor()

model.documentInfo.destinations)%%>
而不是一个foreach

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

是否可以获取EditorFor()显示的项目的数字索引


编辑:我想使用编辑器模板内的索引为模板中的字段生成自定义增量名称/ID。

尝试创建类型为
IList
的强类型模板

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

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


似乎没有,您无法访问使用
EditorFor()生成的集合中字段的数字索引。
您希望在何处使用此索引?我猜是在模板里面?
<%@Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IList>" %>

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