Adding New Entries
RadGridView comes with out-of-the-box insert functionality.
There are three ways to insert a new row in RadGridView:
- By pressing the Insert key
- By clicking on the row which is shown in the control when the
NewRowPositionproperty is set to either Top or Bottom. To learn more about this approach, check this article. - By calling the
BeginInsertmethod
Adding new rows with BeginInsert()
this.radGridView.BeginInsert();When a user adds a new item, an empty row is created in which the user can input data.
The newly created row

If the
IsReadOnlyproperty of RadGridView is set to True or theCanUserInsertRowsproperty is set to False, no row is added. Additionally, the underlying object should expose a default constructor for an empty row to be added.
Modifying New Entries
The next step in implementing the adding functionality is to attach event handlers to the AddingNewDataItem and the RowEditEnded events.
Add handlers for the AddingNewDataItem and RowEditEnded events
<telerik:RadGridView AddingNewDataItem="radGridView_AddingNewDataItem"
RowEditEnded="radGridView_RowEditEnded" />
The AddingNewDataItem event is raised before a new row is added to RadGridView. A typical use case would be when you have to set initial values for an initialized object. You can do this by passing an object to the GridViewAddingNewEventArgs's NewObject property.
The AddingNewDataItem event handler
private void radGridView_AddingNewDataItem(object sender, GridViewAddingNewEventArgs e)
{
var employee = new Employee();
employee.FirstName = "John";
employee.LastName = "Doe";
e.NewObject = employee;
}If the ItemsSource is a DataTable.DefaultView, you can initialize the newly inserted item as shown below:
Adding a new item to a DataTable
private void radGridView_AddingNewDataItem2(object sender, GridViewAddingNewEventArgs e)
{
e.Cancel = true;
var newRow = this.dataSource.DefaultView.AddNew();
newRow["FirstName"] = "John";
newRow["LastName"] = "Doe";
e.NewObject = newRow;
}Via the
OwnerGridViewItemsControlproperty of theGridViewAddingNewEventArgsclass you can access theGridViewItemsControlfor theRadGridViewthat raised the event.
Committing New Entries
The RowEditEnded event is raised when new data is added to RadGridView. This can be done in any of the following ways:
- When the user presses the Enter key.
- When the
CommitEditmethod is called. - When another row is selected.
- When the insert operation is cancelled by pressing the Escape key or calling the
CancelEditmethod.
You can access the EditAction (Commit or Cancel) and the GridViewEditOperationType (Insert or Edit) using GridViewRowEditEndedEventArgs of the RowEditEnded event. It also allows you to access the new data via the NewData property.
Handling the RowEditEnded event
private void radGridView_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
{
if (e.EditAction == GridViewEditAction.Cancel)
{
return;
}
if (e.EditOperationType == GridViewEditOperationType.Insert)
{
//Add the new entry to the data base.
}
}When the new item is committed, it is added to RadGridView's Items collection.
The new row
