Monday, 9 January 2012

How to Generate Dynamic Serial Number for GridView Control with Paging?


It is very simple to add serial or sequential number column in a GridView control. Just create TemplateField column in the GridView and add Container.DataItemIndex+1 as inline code. That's it.

Below we have given the sample block of code for your reference.

<asp:GridView ID="GridView1"runat="server"AutoGenerateColumns="false">
  <Columns>
<asp:TemplateField HeaderText="SNO.">
<ItemTemplate>
<%#Container.DataItemIndex+1 %>
ItemTemplate>
asp:TemplateField>
  Columns>
asp:GridView>

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Powered by Blogger