未提交的新行无法删除? [英] Uncommitted new row cannot be deleted?

查看:587
本文介绍了未提交的新行无法删除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在删除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 to false 。它获取或设置一个值,指示是否向用户显示添加行的选项。
Reason: The issue is due to the transaction which is not closed.

Solution : Change the property of the data gridview -> AllowUserToAddRows property to false. It gets or sets a value indicating whether the option to add rows is displayed to the user.


这篇关于未提交的新行无法删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆