CRUD
You can utilize all CRUD operations by working with the DataView property of the RadDataServiceDataSource control and add, edit or remove entities from the collection which is of type DataItemCollection. You can do that either programmatically via the API of the collection or leave the job to RadGridView by binding its ItemsSource to the DataView.
Example 1: Bind the DataView collection to RadGridView's ItemsSource
<Grid>
<telerik:RadDataServiceDataSource Name="customersDataSource" QueryName="Customers" AutoLoad="True">
<telerik:RadDataServiceDataSource.DataServiceContext>
<local:MyNorthwindContext/>
</telerik:RadDataServiceDataSource.DataServiceContext>
</telerik:RadDataServiceDataSource>
<telerik:RadGridView ItemsSource="{Binding DataView, ElementName=customersDataSource}" IsBusy="{Binding IsBusy, ElementName=customersDataSource}" />
</Grid>
Example 2: Submit the changes in the view
private void SubmitButton_Click(object sender, RoutedEventArgs e)
{
this.CustomersDataSource.SubmitChanges();
}
Private Sub SubmitButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.CustomersDataSource.SubmitChanges()
End Sub
In order to reject the changes and reload the original data from the server you need to call the RejectChanges method of the control.
Example 3: Submit the changes in the view
private void RejectButton_Click(object sender, RoutedEventArgs e)
{
this.CustomersDataSource.RejectChanges();
}
Private Sub RejectButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.CustomersDataSource.RejectChanges()
End Sub