Troubleshooting: Update Data
- 4 minutes to read
This article includes the most common data update issues that you may face in GridControl.
GridControl Cells Do Not Update Their Content After Changing Values in Data Item Properties
Problem
When you change the values in data item properties, GridControl does not update content in the cells.
Solution
Check that your data item class implements the INotifyPropertyChanged interface and raises the PropertyChanged event when its properties are modified.
Use one of the following solutions if you do not want to implement the INotifyPropertyChanged interface manually:
- Derive your class from our Mvvm.BindableBase class and implement your data item properties. Refer to the following help article for more information: BindableBase.
- Implement your data item as a POCO class. In this case, use the properties as described in the Bindable Properties section and generate data items with the help of the ViewModelSource class. Refer to the following help article for more information: POCO ViewModels.
- Implement your view model with the help of the source generator. Refer to this help topic to implement the INotifyPropertyChanged interface in your view model: Implement Interfaces.
The Data Source Cannot Support an Update Mechanism
Problem
You cannot change the data item class and implement the INotifyPropertyChanged interface. You still need to refresh the data in the Grid Control.
Solution
- To refresh all cells in the GridControl, use the DataControlBase.RefreshData method.
- To refresh cells in a specific data row, call the DataControlBase.RefreshRow method. Pass a
RowHandle
as a parameter. Refer to the following help article for additional information: Obtain Row Handles.
GridControl Cells Do Not Update Their Content After Changing Values in the Bound Entity Framework Source
Problem
If you bind a GridControl to an Entity Framework source, cells do not update their content when data changes.
Solution
Try the following solutions:
- Use the DataControlBase.RefreshData and DataControlBase.RefreshRow methods to update the cell values.
- Check for property notifications. Make sure the entities implement the INotifyPropertyChanged interface and raise the PropertyChanged event for modified properties.
GridControl Does Not Reflect the Changes After You Add or Remove Data Items
Problem
GridControl does not reflect the changes when you add or remove data items in the data source collection. This issue can happen when you use a data source collection that does not implement the INotifyCollectionChanged interface and does not raise its CollectionChanged event. The result is that GridControl does not receive any notifications about changes in your collection.
Solution
To resolve this issue, use a collection type that implements the INotifyCollectionChanged interface. For example, try the ObservableCollection<T> collection type.
GridControl Does Not Execute Data Management Operation After Data Is Changed Outside the Grid
Problem
Data Grid does not execute data management operations (sorting, filtering, grouping) and does not recalculate summaries when data is changed outside GridControl.
Solution
To force GridControl to update sorting, grouping, filtering, and summaries, set the DataControlBase.AllowLiveDataShaping option to true
.
Note
GridControl can operate differently depending on whether your data item class implements the INotifyPropertyChanged interface and based on your data source collection type. Refer to the following help topic for more information: AllowLiveDataShaping.
Frequent Data Changes Trigger Unnecessary GridControl Updates
Problem
You do not want to update GridControl in response to every data change. You want to update the control on demand.
Solution
Do not implement the INotifyPropertyChanged interface in your data item class. Instead, call the DataControlBase.RefreshData or DataControlBase.RefreshRow method when you want GridControl to display changes made at the data source level. To further improve performance, consider reworking your implementation based on the recommendations outlined in this topic: Frequent Update Performance Enhancement.
GridControl Does Not Update Data in Active Cells Even If INotifyPropertyChanged Is Implemented
Problem
An active cell does not update its content even when you implement INotifyPropertyChanged. When you edit a cell, its active editor does not handle the PropertyChanged event from an underlying data item object. This logic prevents the loss of user edits.
Solution
To update the editor value when your data item raises the PropertyChanged event, you can close and re-open the editor. Use the DataViewBase.CloseEditor and DataViewBase.ShowEditor methods respectively.