[Reserved] C # DataTable inserted in a particular position data by the method InsertAt

During operation Datatable data variables in C #, may be inserted by InsertAt method Rows properties DataTable variable to specify the location position of a line DataTable a new line of data, i.e. to DataTable table specified position insert new data the DataRow, if the inserted when new rows of data using the Add method rows property, it is inserted into the last row of the table position.

Firstly, we have the Demo Datatable variable dataDt configuration information contained in the table 3, respectively, Name, Id, Memo. There is a need to generate a new business needs DataRow object data row, and DataRow object inserted into the first row in the table, specifically implemented as follows:

 DataRow inserDataRow = dataDt.NewRow();
 inserDataRow["Name"] = "王五";
 inserDataRow["Id"] = 23;
 inserDataRow["Memo"] = "第一行";

 dataDt.Rows.InsertAt(inserDataRow, 0); 

The program code signature used as a method to InsertAt void InsertAt (DataRow row, int pos), wherein the data row representative of the new row object DataRow, pos denotes the index position of insertion.

 

Note: The text reproduced from personal bloggers station IT technology small fun house , the original link for the C # to insert a small technical data _IT interest DataTable house in a specific location by InsertAt method .

Bloggers personal technology exchange group: 960 640 092, blogger micro-channel public numbers are as follows:

Guess you like

Origin www.cnblogs.com/xu-yi/p/11246458.html