Click here to Skip to main content
Rate this: bad
good
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
good
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
bindingSource1.DataMember="Customers";
//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
bindingSource1.Filter=filterString;
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 515
1 Maciej Los 340
2 Richard MacCutchan 265
3 BillWoodruff 225
4 Mathew Soji 155
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411028.1 | Last Updated 28 Mar 2012
Copyright © CodeProject, 1999-2014
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