Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding new row to datatable's top

When we use datatable.newrow command, a new empty row added to bottom of rows. However I want newrow to added to top of datatable. How can I make it?

like image 388
mavera Avatar asked Dec 03 '08 16:12

mavera


People also ask

Can you add a new row in the middle of an existing table?

You can add rows to an existing table in two ways: Use Edit > Add Row to enter a new row one-at-a-time. Use File > Import more rows to bring in rows from a file.

How do I add a row to a DataTable in R?

With command rbindlist from the data. table package, we can append dt_add_row and new_row row-wise. Object dt_add_row, shown in Table 2, shows the original data. table with the added row number 6.

How to create a new DataRow in c#?

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.


1 Answers

You use the NewRow to create a row with the same columns. To actually get it into the DataTable, you've got to do

myDataTable.Rows.InsertAt(myDataRow, 0); 

Where 0 is the index you want to insert it at.

like image 75
Nick DeVore Avatar answered Oct 15 '22 00:10

Nick DeVore