0

hello everyone.. i have a question.. i am using datagrid and binding the columns using datatable..i have grid with columns Area, name, date, country, comments. Now i have to filter the data using two list boxes with contains area and name distinct values. if user selects one location or more and on click of submit the data should filter accordingly.. please suggest how to do this..

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by nick.crane
0

If you have a BindingSource you can use the Filter property of this.
It take a string similar to the WHERE part of an SQL query. E.G. "Area='Selected Area 1' OR Area='Selected Area 2'".

In your Submit button get the selected Area and Name values from your listboxes using the SelectedItems collection.

Either append to a string filter; variable or use a StringBuilder to create the filter string you need and set the BindingSource.Filter property.

You will find a simple example here: MSDN BindingSource.Filter Property

Edited by nick.crane: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.