用下面的代码绑定后 bindingNavigator只能显示记录条数,其它按钮都无效,怎么让bindingNavigator能和datagridview关联起来呢?
dadapter = new SqlDataAdapter();
dadapter.SelectCommand = new SqlCommand(selectString, myConn);
dset = new DataSet();
dadapter.Fill(dset, "UserTable");
builder = new SqlCommandBuilder(dadapter);
this.dataGridView1.DataSource = dset;
dataGridView1.DataMember = "UserTable";
bindingSource2 = new BindingSource();
bindingSource2.DataSource = dset;
bindingSource2.DataMember = "UserTable";
bindingNavigator2.BindingSource = bindingSource2;改成下面的 bindingNavigator 就能正常显示,但builder又无效了,不能存盘,为什么两个控件的DataSource一个要设成BindingSource,另一个要设为table呢?
bindingSource2 = new BindingSource();
bindingSource2.DataSource = dset;
bindingSource2.DataMember = "UserTable";
bindingNavigator2.BindingSource = bindingSource2;
dadapter = new SqlDataAdapter();
dadapter.SelectCommand = new SqlCommand(selectString, myConn);
dset = new DataSet();
dadapter.Fill(dset, "UserTable");
builder = new SqlCommandBuilder(dadapter);
this.dataGridView1.DataSource = bindingSource2;请大家帮我改一下代码,让bindingNavigator、dataGridView1、builder同时有效。
dadapter = new SqlDataAdapter();
dadapter.SelectCommand = new SqlCommand(selectString, myConn);
dset = new DataSet();
dadapter.Fill(dset, "UserTable");
builder = new SqlCommandBuilder(dadapter);
this.dataGridView1.DataSource = dset;
dataGridView1.DataMember = "UserTable";
bindingSource2 = new BindingSource();
bindingSource2.DataSource = dset;
bindingSource2.DataMember = "UserTable";
bindingNavigator2.BindingSource = bindingSource2;改成下面的 bindingNavigator 就能正常显示,但builder又无效了,不能存盘,为什么两个控件的DataSource一个要设成BindingSource,另一个要设为table呢?
bindingSource2 = new BindingSource();
bindingSource2.DataSource = dset;
bindingSource2.DataMember = "UserTable";
bindingNavigator2.BindingSource = bindingSource2;
dadapter = new SqlDataAdapter();
dadapter.SelectCommand = new SqlCommand(selectString, myConn);
dset = new DataSet();
dadapter.Fill(dset, "UserTable");
builder = new SqlCommandBuilder(dadapter);
this.dataGridView1.DataSource = bindingSource2;请大家帮我改一下代码,让bindingNavigator、dataGridView1、builder同时有效。
解决方案 »
- xml里事件找不到target??
- 怎么会找不到控件?
- VS2005 C#如何设置光标在第一个textBox?
- 数组,包括控件类数组的问题
- 请教关于Drawing的问题?
- 求助:.net 有无好用的第三方控件--Excel导入、导出(图片、公式、风格的等)
- 一个新闻系统的问题,关于HTTP查询字符串变量的取值问题!(我的分都快没了 只能40分求了!)
- 如何将Tue, 2 Sep 2003 11:40:37 +0800 这样的日期格式转换为2003-9-2 11:40:37?
- 请问在C#的richtextbox 和 textbox 中如何控制内容滚动
- 在RichTextBox中我怎样才能当前光标位于第几行?(RichTextBox是非自动换行)
- C# 序列化存取问题,求救
- 【没分了将就点吧】这样为什么取不到节点? treeNode问题
dadapter.SelectCommand = new SqlCommand(selectString, myConn);
dset = new DataSet();
dadapter.Fill(dset, "UserTable");
builder = new SqlCommandBuilder(dadapter);bindingSource2 = new BindingSource();bindingSource2.DataSource = dset;
bindingSource2.DataMember = "UserTable";this.dataGridView1.DataSource = bindingSource2;bindingNavigator2.BindingSource = bindingSource2;