For add new column we can add AutoNumber column by using Container.DataItemIndex property in Gridview like as follows:
<asp:GridView ID="GridViewMyGrid" runat="server" AllowPaging="True" AutoGenerateColumns="False"
PageSize="10">
<Columns>
<asp:TemplateField HeaderText="Serial Number">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Dept_Id" HeaderText="Department Id"/>
<asp:BoundField DataField="Dept_Name" HeaderText="Department Name"/>
//.....
//.....
</Columns>
</asp:GridView>
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

MeeraPosted Aug 7, 2012, 6:15 AM
Hey, your code is working well but I have got one issue.I have enabled paging in datalist and i am using this code in datalist.But when I move to next page, the number starts from 1 itself for every page.Can you help me solve out this issue?