Filtering DataGrids

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
 
C

ClayB [Syncfusion]

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, "").
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top