Articles in this section
Category / Section

How to filter the records with searching when underlying items source is DataTable in WPF DataGrid (SfDataGrid)?

1 min read

The filtering is not work in the search operation while binding a DataTable to the WPF DataGrid (SfDataGrid). So, you need to convert the DataTable into Dynamic collection to filter the records while searching.

C#:          

private DataTable dataTableCollection;
 
//Gets the data for DataTable object.
dataTableCollection = GetGridData();
 
//Convert DataTable collection as Dyanamic collection.
var dynamicCollection = new ObservableCollection<dynamic>();
foreach (DataRow row in dataTableCollection.Rows)
 {
   dynamic dyn = new ExpandoObject();
   dynamicCollection.Add(dyn);
   foreach (DataColumn column in dataTableCollection.Columns)
    {
      var dic = (IDictionary<string, object>)dyn;
      dic[column.ColumnName] = row[column];
    }
 }
 
DynamicOrders = dynamicCollection;
 

View sample in GitHub

Conclusion

I hope you enjoyed learning about how to filter the records with searching when underlying items source is DataTable in WPF DataGrid (SfDataGrid).

You can refer to our WPF Grid feature tour page to know about its other groundbreaking feature representations. You can also explore our WPF Grid documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied