This question answers how to insert a DataColumn at position 0. Is there a way to do the same thing with a DataRow? Or is that impossible? Thanks.
Hi every one. DataRow[] dr = dt1. Select("name='" + result[k2] + "' and school='" + result1[k3] + "'");.
To create a new DataRow, use the NewRow method of the DataTable object. After creating a new DataRow, use the Add method to add the new DataRow to the DataRowCollection. Finally, call the AcceptChanges method of the DataTable object to confirm the addition.
You use DataTable's NewRow method to return a DataRow object of data table, add values to the data row and add a row to the data Table again by using DataRowCollection's Add method.
Rows is a DataRowCollection which has an InsertAt extension method: DataTable. Rows. InsertAt(DataRow, pos);
DataTable table = //...
table.Rows.InsertAt(row, 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With