C#windows应用程序,bindingSource做数据源时,数据集更新问题
大家好,我是新手,有个问题请教大家。我这里有一个datagridview控件绑定了一个bindingsource数据源,这个bindingsource返回的是Record表里面的所有记录,页面上有一个combobox控件,combobox关联的是Record表里面的operater字段。现在我想根据用户在combobox中选择的内容区更新数据集,比如说:combobox选择的值为“张三”于是让datagridview里面显示Record表里面operater值为张三的记录。我的代码如下:
1------private void Form_record_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“jinshiDataSet.Record”中。您可以根据需要移动或移除它。
this.recordTableAdapter.Fill(this.jinshiDataSet.Record);
}
2------ 点击按combobox所选内容查询时:
string strDetecter = this.toolStripComboBox_detecter.Text;
SqlConnection con = dc.SqlConBind();
con.Open();
SqlDataAdapter sda = new SqlDataAdapter("select * from Record ", con);//where operater=strDetecter", con);
DataTable recordTable = new DataTable();
sda.Fill(recordTable);
this.recordBindingSource.DataSource = recordTable;
this.recordBindingSource.Filter = "operater='strDetecter'";
this.recordBindingSource .Sort = "time DESC, recordId ASC";
con.Close();
dataGridView1.DataSource = this.recordBindingSource;
运行不提示错误但是datagridview里面没有任何数据显示,不知道是什么原因造成的,大家帮忙解决一下问题,小弟万分感激!