We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Ado.Net ColChanging event fire twice

I am working with a GridDataBoundGrid bound to Data Table. While working on the grid and changing cell content, the ColChanging and ColChanged events fire once when i change the value in a cell and a second time when changing row. I am trying to have some logic between cells in the same row (Quatity, UnitPrice, Total Price) and this behaviour is changing the data twice making unexpected mistakes. Any Suggestions? Thanks, Eli

1 Reply

AD Administrator Syncfusion Team July 13, 2003 03:43 PM UTC

I am not sure whether this will work in your case, but you can try doing your work once by identifying when you are getting the ColumnChanging from with RowLeave. Below are some code snippets showing how this might be done.
private bool inRowLeave = false;
private void gridDataBoundGrid1_RowLeave(object sender, GridRowEventArgs e)
{
	inRowLeave = true;
}

private void gridDataBoundGrid1_RowEnter(object sender, GridRowEventArgs e)
{
	inRowLeave = false;
}

private void datatable_ColumnChanging(object sender, DataColumnChangeEventArgs e)
{
	if(!inRowLeave)
		Console.WriteLine("datatable_ColumnChanging " + e.Column.ToString() );
}

Loader.
Up arrow icon