Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
Hey Guys,
I've been looking for a solution to apply multiple filtration using text boxes and showing the result in Data grid view. This data is imported form SQL Server and p-printed to datagridview.
Thanks and Regards
Aryan Kukreja
Posted 27-Mar-12 19:14pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The following procedure can be used.
//Create a binding source
BindingSource bindingSource1 = new BindingSource();
//Set the datasource property of bindingsource to the DataSet
bindingSource1.DataSource = NorthWindDataset1;
//Set the DataMember property to the required DataTable
//Set the DataSource property of DataGridView to the BindingSource
dataGridView1.DataSource = bindingSource1;
//Create a button and in the Click event of button insert the following code
//Now to apply multiple filter, create a filter string based on the data of the text boxes
string filterString = string.Format("CustomerID='{0}' and City='{1}' and Region='{2}",textBox1.Text.Trim(), textBox2.Text.Trim(), textBox3.Text.Trim());
//set the filter of bindingSource1

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web03 | 2.8.150129.1 | Last Updated 28 Mar 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100