"Cannot execute" Like "on System.Decimal and System.String."

I have problems with searching by DataGridView by price (decimal), this code works for row types, but gives an error when trying to search for prices: "It is impossible to execute" Like "on System.Decimal and System. String".
Here is the code:

 BindingSource bs = new BindingSource(); bs.DataSource = dataGridView1.DataSource; bs.Filter = "price like '%" + Convert.ToDecimal(textBox16.Text) + "%'"; dataGridView1.DataSource = bs; 
+4
source share
1 answer

You are trying to use decimal as a string , so you get an error. You must use the operator for numeric values ​​such as <, >, = , etc.

 BindingSource bs = new BindingSource(); bs.DataSource = dataGridView1.DataSource; bs.Filter = "price > " + Convert.ToDecimal(textBox16.Text) ; dataGridView1.DataSource = bs; 
+2
source

All Articles