Sometimes I want to show the e.Row.RowIndex of a GridViewRow in the markup of the page. I don’t want to hook into the RowDataBound method just to display a simple number. The answer varies for GridViews and Repeaters. Click here for the complete rundown.
GridView:
<asp:Literal runat="server" Text='<%# Container.DataItemIndex + 1 %>' />
Repeater:
<asp:Literal runat="server" Text='<%# Container.ItemIndex + 1 %>' />