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-";