DataSet中已经填充了数据,绑定了DataGrid,并且创建了CommandBuilder对象在DataGrid中修改了DataSet的数据以后,可以用oleDbDataAdapter.Update()提交,没有问题。  现在又把这个DataSet绑定到TextBox上面。这样用鼠标选中DataGrid中的一行,在TextBox上面就可以显示DataGrid中这行的内容。  好,问题来了,在TextBox里面修改了数据以后,直接oleDbDataAdapter.Update()提交,数据并没有提交到数据库里去,但是好像DataSet中的值也变了。如果TextBox的值修改了以后,再在DataGrid中选中其它的行以后,此时修改了的值才在DataGrid反映出来,然后再用oleDbDataAdapter.Update()提交,这时数据才真正提交到数据库中去,这是为什么?有没有什么办法直接Update()就行?

解决方案 »

  1.   

    reference:
    http://www.syncfusion.com/faq/windowsforms/search/1017.aspx
      

  2.   

    把代码贴出来吧。
    首先应该有个acceptchange什么的东西。记不太清了。自己查资料吧。msdn上就有
      

  3.   

    你们不是看不懂,而是你们懒得看,其实我描述得已经很清楚了。
    愚翁就看懂了我的意思,这样做就可以完成我的要求了,多谢。我把它复制过来。
    I programatically change a bound TextBox value, but the value does not get pushed back into the bound datasource. How can I make sure the DataSource is updatedYou can call the EndCurrentEdit method on the bindingmanager for the TextBox.[C#]
         this.textBox1.Text = "XXXX"; //set the value
         this.textBox1.DataBindings["Text"].BindingManagerBase.EndCurrentEdit(); //end the edit[VB.NET]
         Me.TextBox1.Text = "XXXX"
      

  4.   

    http://community.csdn.net/Expert/topic/4841/4841942.xml?temp=.3180658
      

  5.   

    [C#]
         this.textBox1.Text = "XXXX"; //set the value
         this.textBox1.DataBindings["Text"].BindingManagerBase.EndCurrentEdit(); //end the edit
    或者可以这样做
    this.this.BindingContext[dataSet].EndCurrentEdit();
      

  6.   

    需要提交编辑修改,
    http://blog.csdn.net/zhzuo/archive/2005/01/03/238273.aspx