Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
3.40/5 (2 votes)
See more:
Hi all,

I am adding the row in dynamically to datagridview.

how can i remove this?

my code is:
C#
DataGridViewRow row = new DataGridViewRow();
Testdatagridview.Rows.Add(row); 

Remove code
C#
Testdatagridview.Rows.RemoveAt(e.RowIndex);

Error:
uncommitted row cannot be deleted datagridview.
Thanks in advance.
Posted
Updated 26-Oct-12 23:38pm
v4

1 solution

Call
ASM
table.AcceptChanges(); 
for the data to get committed to the table, before trying to remove the row.

http://msdn.microsoft.com/en-us/library/system.data.datarow.acceptchanges.aspx[^]
 
Share this answer
 
v3

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