2012-04-04 9 views

Odpowiedz

29

Spróbuj wykonać następujące czynności:

<asp:Repeater ID="myRepeater" runat="server"> 
    <HeaderTemplate> 
     <table> 
    </HeaderTemplate> 
    <ItemTemplate> 
     <tr> 
      <td><%# Container.ItemIndex %></td> 
      <!-- or maybe --> 
      <td><%# Container.ItemIndex + 1 %></td> 
      <td><%# DataBinder.Eval(Container, "DataItem.Name") %></td> 
     </tr> 
    </ItemTemplate> 
    <FooterTemplate> 
     </table> 
    </FooterTemplate> 
</asp:Repeater> 
+1

Może użyć '<% # Container.ItemIndex + 1%>', aby uzyskać numer oparty na 1. –

+0

Pozdrowienia, dodałem to. Zakładam, że to zadziała :) Mój własny przypadek użycia używa indeksu opartego na zera. – Rawling

+1

Użyłem 'DataBinder.Eval (Container," ItemIndex ")' – Marcel

Powiązane problemy