本文介绍了如何在运行时设置过滤器?对于C#,Winforms,DevExpress中的gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在运行时附加了新的DataSource和DataSet。我也在运行时设置过滤器,但它显示错误找不到列[invoice_number]
我的代码是
Hi, I attach new DataSource and DataSet on Run Time. I set filter also in the Run Time but it shows error ""Cannot find column [invoice_number]"
my code is
// Create a connection object.
OleDbConnection connection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/Srihari/OrionSystem.accdb");
// Create a data adapter.
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM gridview", connection);
// Create and fill a dataset.
DataSet sourceDataSet = new DataSet();
adapter.Fill(sourceDataSet);
// Specify the data source for the grid control.
gridControl1.DataSource = sourceDataSet.Tables[0];
invoiceBindingSource.Filter = string.Format("invoice_number = '{0}'", textEdit5.Text);// error show n this line
但我的OrionSystem Access数据库在表gridview中有invoice_number列。我的错误是什么?
but my OrionSystem Access Database having the Column "invoice_number" in the table gridview. What is my error ?
推荐答案
DataTable DataTable = null;
DataTable = sourceDataSet.Tables(0);
if (Information.IsDBNull(DataTable) == false) {
DataView dataView = DataTable.DefaultView;
dataView.Sort = "invoice_number asc";
GridView1.DataSource = dataView;
GridView1.DataBind();
}
这篇关于如何在运行时设置过滤器?对于C#,Winforms,DevExpress中的gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!