.NET MAUI DataGrid Data Binding: Binding to DataTable
As of the Telerik UI for .NET MAUI 5.1.0 version, the .NET MAUI DataGrid provides full and seamless support for all its features in the DataTable.
The component enables you to bind it to the DataTable and you can also add, remove, select, and edit DataGrid items, and update the DataGrid ItemsSource
. All available DataGrid commands and operations, like filtering, sorting, grouping, and selection, are fully functioning when the DataGrid is bound to a DataTable.
Binding
The following example shows a sample DataGrid ItemsSource
binding to a DataTable:
1. Define the DataGrid.
2. Add the namespace.
3. Set the ViewModel
.
For a full data-binding implementation of a DataGrid to a DataTable, see the
DataGrid/DataTable
folder of the SDKBrowser Demo Application.
Filtering, Sorting, and Grouping
When using a DataTable, you can filter, group, and sort the data inside the DataGrid through the UI or programmatically.
CRUD Operations
All CRUD operations, such as adding, removing, and updating the data inside the DataGrid, are supported when the DataGrid is bound to a DataTable.
1. Define the DataGrid.
2. Add a row.
3. Delete a row.
4. Update the data.
For a full CRUD operations implementation of a DataGrid when bound to a DataTable, see the
DataGrid/DataTable
folder of the SDKBrowser Demo Application.
Commands
All commands supported by the DataGrid are fully applicable when the component is bound to a DataTable. For the full list, see the article with the available commands in the DataGrid.
For a sample implementation of the DataGrid commands in a DataTable, see the
DataGrid/DataTable
folder of the SDKBrowser Demo Application.
Binding When Using a Cell Content Template
When you use a CellContentTemplate
in the built-in columns and you need to bind a property from the business model to a UI element inside the template, you must use indexer syntax. Review the Specifying the Binding for a CellContentTemplate
in Telerik .NET MAUI DataGrid with DataTable article for more details on how to achieve this.