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的程序,我想删除整行,但是现在只能添加不能删除更改,各位大侠救救啊
你的错误提示里已经说明了,应该给你的数据源添加删除的方法。
主键的问题,解决