未提交的新行无法删除? [英] Uncommitted new row cannot be deleted?
问题描述
我在删除datagrid视图中的行时出错。它说
I got an error on deleting a row in datagrid view. It say
Uncommitted new row cannot be deleted.
我尝试过:
foreach(dataGridViewRow dr in dataGridView1.SelectedRows)
{
decimal total_to_be_remove = Convert.ToDecimal(dr.Cells [caltotal]。Value);
dataGridView1.Rows.Remove(dr );
txtsubtotal.Text =(Convert.ToDecimal(txtsubtotal.Text) - total_to_be_remove).ToString();
}
What I have tried:
foreach (DataGridViewRow dr in dataGridView1.SelectedRows)
{
decimal total_to_be_remove = Convert.ToDecimal(dr.Cells["caltotal"].Value );
dataGridView1.Rows.Remove(dr);
txtsubtotal.Text=(Convert.ToDecimal(txtsubtotal.Text) - total_to_be_remove).ToString();
}
推荐答案
原因:问题是由于未关闭的交易造成的。
解决方案:更改数据gridview的属性 - >AllowUserToAddRows
property tofalse
。它获取或设置一个值,指示是否向用户显示添加行的选项。
Reason: The issue is due to the transaction which is not closed.
Solution : Change the property of the data gridview ->AllowUserToAddRows
property tofalse
. It gets or sets a value indicating whether the option to add rows is displayed to the user.
这篇关于未提交的新行无法删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!