I am using DataView and RowFilter. Only one column is filtering,
but I want all columns to be filtered.
I would like to search for a word in the text box to make this filter.
DataView dv = dt.DefaultView;
if (e.KeyChar == (char)13)
{
dv.RowFilter = string.Format("Name LIKE '%{0}%'" ,textBox1.Text );
// dv.RowFilter = string.Format("Date LIKE '%{0}%'", textBox1.Text);
}
The columns headers name = Name, Date, and so on.
Format should be like this for multiple columns;
dv.RowFilter = "Column1 = " + value1 + " AND Column2 = " + value2;
According to your scenario;
dv.RowFilter = string.Format("Name LIKE '%{0}%' AND Date = {1}" ,textBox1.Text, DateValue );
(dataGridView1.DataSource as DataTable).DefaultView.RowFilter = string.Format("Name = '{0}'", TextBoxForSearch.Text);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With