How To Print The Current Row Number In An ASP.NET Repeater Control

Use:

<%#(((RepeaterItem)Container).ItemIndex+1).ToString() %>

Example implementation 1:

<asp:Repeater ID="rep1" runat="server' DataSourceID="myds">
<ItemTemplate>
<%#(((RepeaterItem)Container).ItemIndex+1).ToString() %>
<-- other data binding expressions here... -->
</ItemTemplate>
</asp:Repeater> 

Example implementation 2:

 <td class="c1">
   <b>  
      <%--    
         1. CVS
         109 South High Street
         Columbus, OH 43215
         Get Directions
        --%>
      <%#(((RepeaterItem)Container).ItemIndex+1).ToString() %>.
      <%# Eval("LocationName")  %></b><br />
      <%# Eval("Address")%><br />
      <%# Eval("City")%>,
      <%# Eval("State")%>
      <%# Eval("Zip")%>
     <br />
      <a target="_blank" href='http://maps.google.com/maps?f=q&hl=en&q=from:<%= AddressEntered %>+to:<%# Eval("address") %>, <%# Eval("city") %>,<%# Eval("state") %>,<%# Eval("zip") %>'>Get Directions</a>
</td>

2 thoughts on “How To Print The Current Row Number In An ASP.NET Repeater Control

Leave a comment