Filtering DataGrids

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'd like to bind a DataTable from a DataSet to a DataGrid and apply some filters on the table. The crucial part is that the dataSource is the DataSet and the DataTable is just the dataMember, which is achieved by dataGrid.SetDataBinding(dataSet, dataTable)

The problem is how to apply the row filter on the table: when I set the RowFilter property on the table's DefaultView, nothing happens. Interestingly, the same code works if I bind the table directly with dataGrid.SetDataBinding(dataTable, "")

Does anybody know how to filter the table

Thanks in advanc
Alex
 
Try getting the dataview from the CurrencyManager..

Dim cm as CurrencyManager =
CType(me.DataGrid1.BindingContext(me.DataGrid1.DataSource,
me.DataGrid1.DisplayMember), CurrencyManager)
Dim dv as DataView = CType(cm.List, DataView)
dv.RowFilter = yourRowFilter

============================
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools


Alex said:
I'd like to bind a DataTable from a DataSet to a DataGrid and apply some
filters on the table. The crucial part is that the dataSource is the DataSet
and the DataTable is just the dataMember, which is achieved by
dataGrid.SetDataBinding(dataSet, dataTable).
The problem is how to apply the row filter on the table: when I set the
RowFilter property on the table's DefaultView, nothing happens.
Interestingly, the same code works if I bind the table directly with
dataGrid.SetDataBinding(dataTable, "").
 
Back
Top