Here, there are several simple and easy ways: add a sequence code to the data source as follows: // Get the data source MySelectCommand = "Select * from table";
Sqldataadapter mycommand = new sqldataadapter (MySelectCommand, MyConnection);
DataTable DT = New DataTable (); MyCommand.Fill (DT); // Pay the result of the database to DT to further operate // add sequencing Dt.columns.Add ("index" to DT ("IND) ); // plus sequencing int index; for (index = 0; index
<% # container.itemindex 1%> itemtemplate> asp: templateColumn> columns> ask: DataGrid>
This method is simple, but it is impossible to apply in the case of paging. 2. Implement the properties of .Items.count in the DataGrid itself
<% # this.dataGrid1.items.count 1%> itemtemplate> asp: templateColumn> Columns> ask: dataGrid>
In the case of paging, the code is as follows: