3 Answers, 1 is accepted
You can add a new row at the end of the Rows collection through the GridViewRowCollection.Add method. Here is the needed code:
this.radGridView1.Rows.Add ( "John Smith", 25, 4.98, "555-345-345" );
this.radGridView1.Rows.Add ( new object[] { "John Smith", 25, 4.98, "555-345-345" } );
If you wish to insert a row at a specific position use the API of your binding source. For example if the grid is bound to a DataTable use the following code:
DataRow row = table.NewRow();
table.Rows.InsertAt(row, 5);
If you have any further questions or troubles please feel free to write us.
Kind regards,
Jack
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

I'm affraid, the solution you recommended doesn't work for me.
Here is my code:
DataTable
dataTable1 = new DataTable();
dataTable1.Columns.Add("Id");
dataTable1.Columns.Add("Name");
radGridView1.DataSource = dataTable1;
DataRow dataRow1 = dataTable1.NewRow();
dataRow1["Id"] = 1;
dataRow1["Name"] = "Bob";
DataRow dataRow2 = dataTable1.NewRow();
dataRow2["Id"] = 2;
dataRow2["Name"] = "Alice";
dataTable1.Rows.InsertAt(dataRow1, 0);
dataTable1.Rows.InsertAt(dataRow2, 0);
At this point, radGridView1 freezes, and if I try to click on it, the whole form crashes with an exception at this point:
Application.Run(new Form2());
There seems to be an inconsitency between radGridView1 and its data source, dataTable1: dataTable1 contains two rows correctly, however, radGridView1 shows only the last inserted row ( {2, "Alice"} ), and crashes when attempting any further interaction on the GUI.
I'd be glad to find out if there is a solution.
Thanks,
Tamás
Thank you for contacting us.
I confirm that there is an issue in when inserting rows in RadGridView. You can work around this issue by setting the data source after inserting the rows. Take a look at the following code:
DataTable dataTable1 = new DataTable(); |
dataTable1.Columns.Add("Id"); |
dataTable1.Columns.Add("Name"); |
DataRow dataRow1 = dataTable1.NewRow(); |
dataRow1["Id"] = 1; |
dataRow1["Name"] = "Bob"; |
DataRow dataRow2 = dataTable1.NewRow(); |
dataRow2["Id"] = 2; |
dataRow2["Name"] = "Alice"; |
dataTable1.Rows.InsertAt(dataRow1, 0); |
dataTable1.Rows.InsertAt(dataRow2, 0); |
radGridView1.DataSource = dataTable1; |
We will address this issue in our upcoming release later this month.
I hope this helps. Do not hesitate to write me if you need further assistance.
All the best,
Jack
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center