C# 行过滤器排序
我在C# 行过滤器排序,c#,datagridview,dataview,C#,Datagridview,Dataview,我在textBox1\u TextChanged上调用了DataViewRowFilter 代码: private void textBox1_TextChanged(object sender, EventArgs e) { DataView dv = new DataView(table); if (comboBox1.SelectedIndex == 0) { dv.RowFilter = "Price ="
textBox1\u TextChanged
上调用了DataView
RowFilter
代码:
private void textBox1_TextChanged(object sender, EventArgs e)
{
DataView dv = new DataView(table);
if (comboBox1.SelectedIndex == 0)
{
dv.RowFilter = "Price =" + textBox1.Text;
}
}
有时这项工作,但在最后一次我收到这个错误
“System.Data.EvaluateException”类型的未处理异常
发生在System.Data.dll中
其他信息:无法对System.String执行“=”操作
和System.Int32
我还尝试将列
Price
从大到小排序。最好的方法是什么 尝试此代码,不要传递空白值,传递0默认值
var s = "8";
dv.RowFilter = "price = "+ s;
但是我已经试过你的代码了。获取错误,因为价格列不在视图中。价格的类型是什么?也许你需要
“Price=“+int.Parse(textBox1.Text)
?它是int
我试过了,但不起作用。