首页 新闻 会员 周边 捐助

数据源绑定后,在testgridview中修改数据后,无法保存(菜鸟求教)

0
悬赏园豆:100 [已关闭问题] 关闭于 2011-09-27 17:32

 private void testBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.testBindingSource.EndEdit();
         //   this.testBindingSource
            this.Validate();
            this.testBindingSource.EndEdit();
            G_PHMDataSet.testDataTable deleteTest = (G_PHMDataSet.testDataTable)
            g_PHMDataSet.test.GetChanges(DataRowState .Deleted);
         

            G_PHMDataSet.testDataTable newtest = (G_PHMDataSet.testDataTable)
            g_PHMDataSet.test.GetChanges(DataRowState .Added );
           


            G_PHMDataSet.testDataTable modifiedtest = (G_PHMDataSet.testDataTable)
            g_PHMDataSet.test.GetChanges(DataRowState .Modified );
           


          //  this.testDataGridView.DataBindings.Clear();

            try
            {
                if (deleteTest != null)
                {
                    this.testTableAdapter.Update(deleteTest  );
                   
                   
                }

                if (newtest != null)
                {
                    this.testTableAdapter.Update(newtest );
                  
                }

                if (modifiedtest != null)
                {
                    this.testTableAdapter.Update(modifiedtest );
               
                }
              //  this.testDataGridView.DataBindings.Clear();
             

                g_PHMDataSet.AcceptChanges();
            }

            catch (Exception ex)
            {
                MessageBox.Show("无法更新..."+ex.Message );
            }
           // this.testTableAdapter.Update(this.g_PHMDataSet.test);

        }这是保存控件即2的程序,我想删除整行,但是现在只能添加不能删除更改,各位大侠救救啊

天黑了的主页 天黑了 | 初学一级 | 园豆:110
提问于:2011-09-23 15:30
< >
分享
所有回答(2)
0

你的错误提示里已经说明了,应该给你的数据源添加删除的方法。

today4king | 园豆:3499 (老鸟四级) | 2011-09-25 10:27
0

主键的问题,解决

天黑了 | 园豆:110 (初学一级) | 2011-09-25 12:09
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册