Hi all,
My code is below, the code works fine when the strFilterText has a value but if the string is empty then it filters the rows that have no value which are the ones I want to show, for example if strFilterText contains "shoes" then the datagrid shows all the rows that contain "shoes" but if I want to find rows that have no category i.e. the catergory is NULL then strFilterText contains "" and I would like it to return everything with "" in the category but the code below shows me everything with a category if strFilterText is "".
Thanks for the help.
strFilterText += " LIKE '%" + txtboxValue.Text + "%'";
performFilter(strFilterText);
}
private void performFilter(string strFilterText)
{
DataTable table = dataGridView1.DataSource as DataTable;
if (table != null)
{
List<DataRow> filteredRows = new List<DataRow>(table.Select(strFilterText));
CurrencyManager cm = (CurrencyManager)BindingContext[dataGridView1.DataSource];
cm.SuspendBinding();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
row.Visible = filteredRows.Contains(((DataRowView)row.DataBoundItem).Row);
}
cm.ResumeBinding();
}
}