【问题标题】:c# getting current index of generic listc#获取通用列表的当前索引
【发布时间】:2011-04-25 08:25:18
【问题描述】:

如何从表单页面获取通用列表的索引?例如;

aspx.cs

List<string> names = new List<string>();
names.Add("a");
names.Add("b");
names.Add("c");

repeaterNames.datasource = names;
repeaterNames.DataBind();

aspx

<form>
  <repeater>
   <itemtemplate>
    **<%# Eval(?)%>**
   </itemtemplate>
  </repeater>
</form>

【问题讨论】:

  • 清除问题。您到底想要什么?

标签: c# .net list indexing generics


【解决方案1】:

使用ItemIndex:

<ItemTemplate>
    <%# Container.ItemIndex %>
</ItemTemplate>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-12
    • 1970-01-01
    • 1970-01-01
    • 2016-10-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多