New to Telerik UI for WPF? Download free 30-day trial

Cannot insert new row

Adding new items for RadGridView is done via the GridViewNewRow control when the Insert key is pressed. It should appear in the form of an empty row that allows you to enter a value for the field of each column.

PROBLEM

The user cannot add new items to RadGridView.

CAUSE

Generally the reason why you cannot add any new item, is because RadGridView does not know how to create the new object of the Item's type. This is due to the fact that the Item does not have a default constructor.

Another possible reason can be the type of the bound data source collection. If the collection itself does not support inserting and removing items then you will not be able to add any new item.

You can find more information on different types of collections and the functionality they provide in this help article.

SOLUTION

You could subscribe for the AddingNewDataItem event of RadGridView and specify what to be the initial values for every cell in the shown insert row.

For example if you have a collection of Orders when you want to add a new Order you could use the following approach:

private void ordersGrid_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e) 
{ 
    e.NewObject = new Order() { CustomerID = myCustomerID }; 
} 
Private Sub ordersGrid_AddingNewDataItem(sender As Object, e As Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs) 
    e.NewObject = New Order() With { 
     .CustomerID = myCustomerID 
    } 
End Sub 

See Also

In this article