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

how to Handle violating constaints error message in griddatabound

Hello I set the primiary keys of datasource to control duplicate row entry in my grid. if the user enters a duplicate value for the primary key column, they get a built in error generated by the grid itself warning them of this error. Do you know how I can stop this message and use my messagebox ? is there any events I can catch?

5 Replies

AD Administrator Syncfusion Team October 13, 2004 05:20 AM UTC

Hi Yang, you can handle the groupingControl.ExceptionRaised event and set e.Cancel = true. Then you can display your own messagebox there. Stefan

AD Administrator Syncfusion Team October 13, 2004 01:13 PM UTC

If this is a GridDataBoundGrid, then try handling the grid''s ValidateFailed event. There to provide your own message, set grid.CurrentCell.ErrorMessage.
private void gridDataBoundGrid1_ValidateFailed(object sender, GridValidateFailedEventArgs e)
	this.gridDataBoundGrid1.CurrentCell.ErrorMessage = "My message";

AS Abdul Shahzad November 28, 2005 03:08 PM UTC

Hi Clay, This works fine if the user key-in invalid value and leave the cell either by pressing Tab or arrow button or mouse. But fails if Enter key is hit i.e. if the user hit Enter key after invalid value then same Grid''s buil-in error message is show. In clue on how to handle this. Regards, Shahzad

AD Administrator Syncfusion Team November 28, 2005 03:42 PM UTC

One thing that might work is to catch the Enter key and turn it into a Tab key. You can do this by handling the CurrentCellKeyDown event.
private void gridDataBoundGrid1_CurrentCellKeyDown(object sender, KeyEventArgs e)
	if(e.KeyCode == Keys.Enter)
		e.Handled = true;//ignore Enter
		SendKeys.Send("{TAB}");//do a tab

AS Abdul Shahzad November 29, 2005 05:51 AM UTC

Thanks Clay.It work''s fine!!!

Live Chat Icon For mobile
Up arrow icon