I want to override default validation performed by GDBG.
The follow scenario takes place:
User fills new row, and moving to the next row. I''m handling OnRowLeave event, to do some business logic. After calling EndEdit, an exception may be thrown (For example: NoNullsAllowed), since data source constraints disallow submission of grid values. This is fine, but I didn''t find any programmatic way to check which field caused the problem. I''m only getting the exception.
I also tried to catch ValidationFailed event. this event is thrown but is not helpfull in detecting the field and type of error which cause validation to fail!
I can assume about the error type using the exception type, but what about the field which caused this?
How can I detect detect programmaticly the field caused EndEdit to fail?
ADAdministrator Syncfusion Team November 28, 2004 04:52 AM
The grid does not throw this exception, and so does not really know what column caused it. It is your datasource that is throwing this exception.
If you want to try to handle this from a grid event, try catching the CurrentCellAcceptChangesFailed event. There you can get a reference to the exception that was thrown, and from there parse the exception text and get the column that way. I think you would have to have a case for each exception you wanted to handle.
private void gridDataBoundGrid1_CurrentCellConfirmChangesFailed(object sender, EventArgs e)
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
int start = cc.ErrorMessage.IndexOf("''");
if(start > -1)
int end = cc.ErrorMessage.IndexOf("''", start + 1);
if(end > -1)
string colName = cc.ErrorMessage.Substring(start + 1, end - start - 1);