Click here to Skip to main content
16,019,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I got an error on deleting a row in datagrid view. It say
C#
Uncommitted new row cannot be deleted.


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();
}
Posted
Updated 16-Feb-20 18:41pm

1 solution

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.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900