Saturday, May 03, 2025

Breaking News
>> Securing and encrypt View State and Cookies values  >> Page has one or more controls that do not correspond with   >> “The Controls collection cannot be modified because the control contains code blocks”  >> How to fix "Validation(): Element 'xxxx' is not supported  >> How to create a new session in ASP.NET programmatically  >> MySQL Database Backup using mysqldump command    

Editors Picks

Monday, January 9, 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>

No comments :

Post a Comment

Contact Us

Name

Email *

Message *