Hello I have a datatable that I would like to filter with a single textbox, non-case sensitive. In other words when a user starts typing into the textbox, I would like the RowFilter to display any rows that CONTAIN the typed information (again regardless of case).
My current code will only display exact matches and only for a single column (“ID”). There are a few other columns I want to include, i.e. “Title”, “User Name”, “Company”, etc.
Any ideas?
private void searchTextBox_TextChanged(object sender, EventArgs e)
{
if (searchTextBox.Text.Trim() != "")
{
gridToTable.DefaultView.RowFilter = "ID = " + searchTextBox.Text;
}
else
{
gridToTable.DefaultView.RowFilter = string.Empty;
}
}
You can use
LIKEin theRowFilterand concat all flters withOR.DataColumn.Expression Property(same syntax forDataView.RowFilter)But to be honest, i would suggest to use
LINQ-to-DataSetinstead since it’s much more powerful.For example: