Add index serial numbers to DataGrid, automatic number

xiaoxiao2021-03-06  36

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%>

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%>

In the case of paging, the code is as follows:

转载请注明原文地址:https://www.9cbs.com/read-62285.html

New Post(0)