我想添加一行篩選功能在我的DataGridView但不斷收到以下錯誤消息:行篩選器崩潰,System.Data.EvaluateException C#應用程序是未處理的消息
System.Data.EvaluateException was unhandled
Message: An unhandled exception of type 'System.Data.EvaluateException' occurred in System.Data.dll
Additional information: Cannot perform 'Like' operation on System.Int32 and System.String.
這種情況發生,每次我在我的文本框中輸入內容。任何想法爲什麼?代碼如下:
的App.config
Form1.cs的
// driver no search
private void driverNo_TextChanged(object sender, EventArgs e)
{
BindingSource bs = new BindingSource();
bs.DataSource = dataGridView1.DataSource;
bs.Filter = "DriverNo like '%" + driverNo.Text + "%'";
dataGridView1.DataSource = bs;
}
邊評論:我不沒有想到製作一個無限深的巢穴層次ed BindingSources是一個好主意。 –
謝謝 - 你會建議什麼?這是我在論壇上遇到的最簡單的方法 – theshizy
最簡單的方法是始終使用一個BindingSource,然後相應地設置Filter屬性,而不是創建新的和嵌套。 –