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
Violeta Popa
NA
137
161.2k
filter a datagrid
Mar 17 2013 6:47 PM
Hy :) i'm trying to filter a datagrid by name ( i have a textbox ) and by client type ( combobox with options: all, personal and other ), and i have a button which clears the criteria. The filtering works fine, but when clearing the criteria and the option is personal/other the datagrid shows only personal/other clients..not all of them..and i don't know how to fix it. Here's the code:
private void filter(string name)
{
if (comboBox1.SelectedItem.ToString() == "Personal")
{
clientGridView.DataSource = dataSet.Tables["client"].DefaultView;
dataSet.Tables["client"].DefaultView.RowFilter = "client_type LIKE 'personal' AND name LIKE '%" + name + "%'";
}
else
if (comboBox1.SelectedItem.ToString() == "Other")
{
clientGridView.DataSource = dataSet.Tables["client"].DefaultView;
dataSet.Tables["client"].DefaultView.RowFilter = "client_type LIKE 'other' AND name LIKE '%" + name + "%'";
}
else
{
try
{
clientGridView.DataSource = dataSet.Tables["client"].DefaultView;
dataSet.Tables["client"].DefaultView.RowFilter = "client_type LIKE '%' AND name LIKE '%" + name + "%'";
}
catch { }
}
}
and for the clear button
textBox1.Clear();
comboBox1.SelectedItem = "-choose-";
Reply
Answers (
2
)
Print patter
After pressing enter key - there is a msg in Windows 7