How to print the current row number in an ASP.NET Repeater control

Here's a quick way to print the current row number in a Repeater control (I promised a conference talk attendee to post this recently):

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


Posted Mar 31 2008, 10:34 AM by fritz-onion
Filed under:

Comments

真见 wrote Always 英文技术文章参照( 三 ){ UpdateTime:2008-7-5; } My article in the cnblogs
on 07-05-2008 9:31 AM

1.微软ASP.NET2.0CSSFriendlyControlAdapters。www.asp.net/.../WhitePaper.aspx...

cnblogs.com wrote Always 英文技术文章参照( 三 ){ UpdateTime:2008-7-5; } My article in the cnblogs
on 07-05-2008 10:27 AM

1.微软ASP.NET 2.0 CSS Friendly Control Adapters。 www.asp.net/.../WhitePaper.aspx

Add a Comment

(required)  
(optional)
(required)  
Remember Me?