Tuesday, February 21, 2006

Create a simple Serial/row No column in Datagrid/DataList

A very simple way to create Serial/row No column in Datagrid/DataList

create a variable in the code behind


protected int i=1;

Now in the Datagrid/DataList add a TemplateColumn with data bound to the variable



<asp:TemplateColumn HeaderText="SL#">
<ItemTemplate>
<%# i++ %>
</ItemTemplate>
</asp:TemplateColumn>


This may not be usefull for item identification when used in sortable grid