views:

2027

answers:

3

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?

+7  A: 

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(0,myDataRow);

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

Nick DeVore
myDataTable.Rows.InsertAt(myDataRow,0); is the correct form. Thanks
mavera
A: 

Thanks for the information

GAJ
A: 

This One is Wrong

myDataTable.Rows.InsertAt(0,myDataRow);

Please use the below line instead of that

myDataTable.Rows.InsertAt(myDataRow,0);

Ksamy
I have written correct form as a comment of accepted answer. You can see it above.
mavera