You can use the template column of the gridview in ASP. net2.0 to conveniently Add rows in the gridview.
To view the row number after turning the page, set the allowpaging attribute of the gridview to true.
First, add a template column for columns of the gridview in design mode, and move the template column to the first column.
Add the following in the rowdatabind event of the gridview:CodeTo display the number of records:
Protected void gridview1_rowdatabound (Object sender, gridviewroweventargs e) {If (this. gridview1.pageindex = 0) {If (E. Row. rowindex! =-1) {e. row. cells [0]. TEXT = convert. tostring (E. row. rowindex + 1) ;}} else {int start = This. gridview1.pageindex * This. gridview1.pagesize; If (E. row. rowindex! =-1) {e. Row. cells [0]. Text = convert. tostring (E. Row. rowindex + start + 1 );}}
}
Click it to view the row number of the record in the first column of the gridview.