0
Posted on 9:02 AM by prajeesh and filed under ,
In many situations we may need to add auto number or serial numbers in grid view column, but we cannot find a property in property window to add this.
We can add auto number column in Grid view or Data List by using Container.DataItemIndex property in Gridview or Data List mark up.

Add a Template field and add following code in Grid view Mark up:

<asp:TemplateField HeaderText="Serial Number">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField> Shout it kick it on DotNetKicks.com
0
Responses to ... Add auto number column in Gridview