Click here to Skip to main content
Sign Up to vote bad
good
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 - 18:14


1 solution

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
Your Filters
Interested
Ignored
     
0 OriginalGriff 325
1 Mohammed Hameed 123
2 Sergey Alexandrovich Kryukov 115
3 Santhosh G_ 103
4 Ron Beyer 89
0 Sergey Alexandrovich Kryukov 8,286
1 OriginalGriff 6,561
2 CPallini 3,533
3 Rohan Leuva 2,703
4 Maciej Los 2,234


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