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
Tuesday, February 21, 2006
Create a simple Serial/row No column in Datagrid/DataList
Subscribe to:
Post Comments (Atom)
4 comments:
But prashant this doesnot work for a pageable datagrid/gridview control.
Hey Prashant it works fine with datalist
thanks buddy :)
Hi prashanth,
It works for Datlist, but the problem is,datlist is implemented with pagination,so in the next page the numbers are again displayed from 1.
We should be able to initialize the i with page# * #of rows/page in the page index change event
Post a Comment