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

Validating cell input best practise

Between these three events, where would be the best consistent place to do input validation and perform do manual manipulation to the underlying datasource?

1. CurrentRecordContextChange
2. TableControlCurrentCellValidating
3. TableControlCurrentCellEditingComplete

Here are some requirements.
I would like access to the column and row index of the cell, the old and new value of the cell, and the underlying datarowview or record.

Users will be using the up/down/left/right arrow keys to navigate and changin values quickly, i.e., the values in the cell are by selected by default.

1 Reply

AD Administrator Syncfusion Team September 14, 2006 05:57 AM UTC

Hi James,

The recommended solution is to handle TableControlCurrentCellValidating event for validating the cell data in a grid. So, Please try these code and see if it helps.

GridCurrentCell currentCell = e.TableControl.CurrentCell;
GridTableCellStyleInfo style = cc.Renderer.CurrentStyle as GridTableCellStyleInfo;

To get the RowIndex, use below code snippet.
int RowIndex = currentCell.RowIndex;

To get the ColIndex, use below code snippet.
int ColIndex = currentCell.ColIndex;

To get the OldValue, use below code snippet.
object OldValue = style.CellValue;

To get the NewValue, use below code snippet.
object NewValue = cc.Renderer.ControlValue;

To get the CurrentRecord, use below code snippet.
Record rec = e.TableControl.Table.CurrentRecord;

To get the CurrentDataRowView from CurrentRecord , use below code snippet.
Record rec = e.TableControl.Table.CurrentRecord;
DataRowView drv = rec.GetData() as DataRowView;

Please refer to the below KB article for more details on Validation of a cell.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=340

Let me know if you need any further assistance.

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon