Tuesday, June 26, 2012

add Serial Number in gridview

sometimes we need to add serial numbers in gridview. we can achieve it through following code snippet.
<HeaderTemplate> Serial No. </HeaderTemplate>
<asp:Label ID="lblSRNO" runat="server" Text='<%#Container.DataItemIndex+1 %>'></asp:Label> </ItemTemplate>

This code works as same when we apply paging.

We cannot use this on BoundFields because they support only those objects who have Databinding event.

Happy Coding!!

No comments:

Post a Comment