TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nils Olsson
NA
16
1.4k
How to combine 2 dataGridView filters
Mar 22 2018 5:56 PM
I have a Windows Form program in C#.
I have a dataGridView with several columns and where 2 columns are State and Country
I have 2 comboBoxes populated with all items from the State and County
My code for the 2 filters are:
BindingSource bs = new BindingSource();
bs.DataSource = dataGridView1.DataSource;
bs.Filter = "[State] Like '%" + FilterState.Text + "%'" ;
dataGridView1.DataSource = bs;
BindingSource bs = new BindingSource();
bs.DataSource = dataGridView1.DataSource;
bs.Filter = "[Country] Like '%" + FilterCountry.Text + "%'";
dataGridView1.DataSource = bs;
This 2 filters work OK separately, but I also need have both filters active together..
I am trying to make a combination of these 2 filters
bs.Filter = "[State] Like '%" + FilterState.Text + "%'" AND "[Country] Like '%" + FilterCountry.Text + "%'";
But, the line above is not working. How can I do it? Or must I have a totally different approach to ahve multiple filters
Reply
Answers (
1
)
CRUD operations with SQL Server Management Studio
How to display next letter using button in c#