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>
Advertisements

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s