Skip to content

khamlyuk/blazor-DxDataGrid-bind-to-DataTable

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Files to look at:

Blazor Data Grid - How to bind a grid to a DataTable object

DxDataGrid can be bound only to the IEnumerable collection of objects. So, a DataTable object cannot be directly passed to the DxDataGrid.Data property.

In the case when the structure of the used DataTable is known, it's possible to create a class with corresponding properties for each column in the DataTable object. Then it's necessary to generate the IEnumerable collection of this class' objects based on the Rows collection of the DataTable object. This approach is demonstrated in the first "Static object" grid.

In some cases, the DataTable object is generated dynamically and its structure is not known. For this scenario, our DxDataGrid supports binding to the IEnumerable collection of the ExpandoObject objects. It's possible to dynamically generate properties in such objects based on the structure of the used DataTable. This approach is demonstrated in the second "Dynamic object" grid. Check the ConvertDataTableToExpandoObjectList method which converts the DataTable object to the IEnumerable collection of the ExpandoObject objects.

Releases

No releases published

Packages

No packages published

Languages

  • HTML 54.9%
  • C# 45.1%