This is a migrated thread and some comments may be shown as answers.

HowTo: Filtering grid associated with Datatable

0 Answers 103 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jorge Gonzalez
Top achievements
Rank 1
Jorge Gonzalez asked on 11 Jan 2010, 06:03 PM
Hello,
    I finally figured out how to filter a grid associated with a datatable. Instead of filtering the grid, which was a traumatic experience, I filtered the datatable associated with the grid instead. It took less than 7 lines of code and most of those lines of code were for creating the filter expression:

I am collecting a bunch of values in another window so I can filter the varnames column in my grid so:

string filterexpression = "varnames in (" + < bunch of values> + ")"
gridname.ItemsSource = <datatable name>.Select(filterexpression, <supply sort expression>, DataViewRowState.CurrentRows);

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Jorge Gonzalez
Top achievements
Rank 1
Share this question
or