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

TableControlCurrentCellValidating being called twice for same operation

I have a cell in which a user can enter a have and press the enter key. I then do so validation in the TableControlCurrentCellValidating event.

However, I noticed that the TableControlCurrentCellValidating is being called twice for the same operation. When I enetr a value in the cell, the is called and they called again, causing the adverse effect in my logic.

I have something like this in the event..

... if logic is true then..

this.gridGroupingControl1.TableControl.BeginUpdate();


DataRow rowLine = rec.GetData() as DataRow;
rowLine.BeginEdit();
rowLine[columnName] = NewWeekSpot;
rowLine.EndEdit();

e.TableControl.Table.CurrentRecord.EndEdit();


this.gridGroupingControl1.TableControl.EndUpdate(true);

5 Replies

AD Administrator Syncfusion Team February 14, 2007 01:00 AM UTC

Hi James,

I am not sure of what be might be causing this strange behavior without a working sample. I have tested this issue in the attached sample with Essentail studio V.4.x. I was not able to reproduce the issue. Maybe I am not following the steps that you are doing. Please post us a sample showing this problem or modify the attached samples to reproduce the problem, which will help me to find the issue and resolve this.

GGCValidateCell.zip

Thanks for your patience.

Best regards,
Haneef


JB James Blibo February 19, 2007 07:04 AM UTC

I have been able to reproduce this issue in the sample that you sent.

I the sample that you sent, you have the following code in the TableControlCurrentCellValidating event...

e.TableControl.BeginUpdate();
Record rec = e.TableControl.Table.CurrentRecord;
DataRowView row = rec.GetData() as DataRowView;
row.BeginEdit();
row["Col1"] = NewValue;
row.EndEdit();
e.TableControl.Table.CurrentRecord.EndEdit();
e.TableControl.EndUpdate(true);


... noticed how you are first casting to a DataRowView before you are made the change to the record.

... However, in my code, I am doing the following...

e.TableControl.BeginUpdate();
Record rec = e.TableControl.Table.CurrentRecord;
rec.BeginEdit();
rec.SetValue("Col1", NewValue);
rec.EndEdit();
e.TableControl.Table.CurrentRecord.EndEdit();
e.TableControl.EndUpdate(true);


...this is when the TableControlCurrentCellValidating is raised TWICE. I see nothing wrong with editing the record thru SetValue, but oviously, this is causing the TableConrolCurrentCellValidating to be raised twice


AD Administrator Syncfusion Team February 20, 2007 09:55 PM UTC

Hi James,

Sorry for the delay in responding to your query.

To resolve this issue, you need to set the CurrentCell.IsModified property to false in the TableControlCurrentCellValidating event of the grid. Please refer to the attached sample for implementation and let me know if this helps.

e.TableControl.BeginUpdate();
Record rec = e.TableControl.Table.CurrentRecord;
rec.BeginEdit();

cc.IsModified = false;

rec.SetValue("Col1", NewValue);
rec.EndEdit();
e.TableControl.Table.CurrentRecord.EndEdit();
e.TableControl.EndUpdate(true);

Sample : Modifiedissue23.zip

Best regards,
Haneef


JB James Blibo February 21, 2007 03:10 AM UTC

What if I have a situation where I am looping thru a record collection and updating a field, the solution that you provided will not work...

If I have something like this...

foreach (Record record in filterSpotRecords) //update child grid
{
record.BeginEdit();

record.SetValue("Length", NewSpotLength);
record.SetValue("CurrentRate", NewRate);
record.EndEdit();
}
versus...

e.TableControl.BeginUpdate();
Record rec = e.TableControl.Table.CurrentRecord;
rec.BeginEdit();
cc.IsModified = false;
rec.SetValue("Col1", NewValue);
rec.EndEdit();
e.TableControl.Table.CurrentRecord.EndEdit();
e.TableControl.EndUpdate(true);

....


How can I set cc.IsModified = true?

This will still cause the TableControlCurrentCellValidation event to be raise twice.


JB James Blibo February 21, 2007 03:20 AM UTC

Never mind my previous post... the event will only be raise for the current cell, so no need for me to worry about updating other records in the datasource... thx for the help

Loader.
Live Chat Icon For mobile
Up arrow icon