因此,每当我运行以下代码时,当comboBox中包含值时,它就会起作用,但是如果值是null
,则会显示:
“无法对System.Double和System.String执行'='操作。”
DataView dv = new DataView(dt);
dv.RowFilter =
"Price = '" + comboBox3.Text +
"' OR Model = '" + comboBox1.Text +
"' OR Supplier = '" + comboBox2.Text +
"' OR TotalPower = '" + comboBox6.Text +
"' OR Battery = '" + comboBox5.Text +
"' OR TireSize = '" + comboBox4.Text +
"' OR TireType = '" + comboBox9.Text +
"' OR Brakes = '" + comboBox8.Text +
"' OR WeightCapacity = '" + comboBox7.Text +
"' OR MinSpeed = '" + comboBox11.Text +
"' OR MaxSpeed = '" + comboBox10.Text + "'";
dataGridView.DataSource = dv;