Recently, is the project to use the DevExpress Aspxgridview control, the request can automatically display line number, now the code share.
ASPX page: ===========================================
<dx:aspxgridview id= "ASPxGridView1" runat= "Server" autogeneratecolumns= "False" keyfieldname= "ID" width= "100%"
Oncustomunboundcolumndata= "Aspxgridview1_customunboundcolumndata"
Clientidmode= "Autoid" >
<Columns>
<dx:gridviewdatatextcolumn caption= "serial number" fieldname= "hh" unboundtype= "Integer" >
</dx:GridViewDataTextColumn>
<dx:gridviewdatacolumn caption= "Work Type" fieldname= "TaskType" >
<DataItemTemplate>
<% #GetProjectNodeName ((int) Eval ("TaskType"))%>
</DataItemTemplate>
</dx:GridViewDataColumn>
</Columns>
</dx:ASPxGridView>
CS Code section: =========================================
///<summary>
/ Display line number
///</summary>
///<param name= "sender" ></PARAM>
///< param name= "E" ></param>
protected void aspxgridview1_ Customunboundcolumndata (object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDataEventArgs e)
{
if ( E.column.caption = = "Serial number" && e.isgetdata)
E.value = (e.listsourcerowindex + 1). ToString ();
}