Row number in GridView — the best way !!!

Written by Deepak Vasa on May 30th, 2008

<asp:TemplateField>
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>

Written by Deepak Vasa - Visit Website
 

1 Comments so far ↓

  1. Deepak Vasa says:

    To add the row number for a GridView with custom paging esp. when using SQL Server 2000:



    < %# (((GridView)((GridViewRow)Container).Parent.Parent).PageIndex) * ((GridView)((GridViewRow)Container).Parent.Parent).PageSize + Container.DataItemIndex + 1 %>

Leave a Comment