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..

Any suggestions please...

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.