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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GDBG custom validation

Thread ID:

Created:

Updated:

Platform:

Replies:

21906 Nov 28,2004 07:33 AM UTC Nov 28,2004 09:52 AM UTC Windows Forms 1
loading
Tags: GridControl
Gil Kalo
Asked On November 28, 2004 07:33 AM UTC

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? Thanks, Gil K

Administrator [Syncfusion]
Replied On November 28, 2004 09:52 AM UTC

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;
	switch (cc.Exception.GetType().ToString())
	{
		case "System.Data.NoNullAllowedException":
		{
			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);
					Console.WriteLine(colName);
				}
			}
		}
		break;
	}
}

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;