Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to insert DataRow into a DataTable at index 0?

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.

like image 840
rosscj2533 Avatar asked Dec 22 '09 13:12

rosscj2533


People also ask

How do I find the index of DataRow?

Hi every one. DataRow[] dr = dt1. Select("name='" + result[k2] + "' and school='" + result1[k3] + "'");.

How do you declare a DataRow?

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.

What is the method used to return the DataRow?

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.

How do you add a row at the top in the DataTable in C#?

Rows is a DataRowCollection which has an InsertAt extension method: DataTable. Rows. InsertAt(DataRow, pos);


1 Answers

DataTable table = //...
table.Rows.InsertAt(row, 0);
like image 60
Doc Brown Avatar answered Oct 12 '22 23:10

Doc Brown