Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.net Repeater get current index, pointer, or counter

the question is really simple. Is there a way to access the current pointer/counter for an asp Repeater control.

I have a list with items and I would like one of the repeaters columns (it repeats and html table) to be something like ...

Item 1 | some info

Item 2 | some info

... and so on

1 and 2 being the counter.

like image 486
Jan W. Avatar asked Jul 01 '09 07:07

Jan W.


1 Answers

To display the item number on the repeater you can use the Container.ItemIndex property.

<asp:repeater id="rptRepeater" runat="server">     <itemtemplate>         Item <%# Container.ItemIndex + 1 %>| <%# Eval("Column1") %>     </itemtemplate>     <separatortemplate>         <br />     </separatortemplate> </asp:repeater> 
like image 121
Binoj Antony Avatar answered Sep 28 '22 05:09

Binoj Antony