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

Databoundgrid - constraintexception

I have a databound grid to a datatable. The grid display only one column. It display's a combobox to select an item. The selected item is the key to the bound datatable. If the user select's an item that is already in the list and moves to another row or control, vb pop'up an error messagebox. What event can I use to trap this message and display something else?

1 Reply

AD Administrator Syncfusion Team January 13, 2003 10:37 PM UTC

Try handling the CurrentCellValidating event, and checking the value there, and setting e.Canceled = True if the action should be cancelled. You can set the currentcell's ErrorMessage to display a particular message.
private void gridDataBoundGrid2_CurrentCellValidating(object sender, CancelEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid2.CurrentCell;
	if(cc.ColIndex == 7)
	{
		string newValue = cc.Renderer.ControlText;
		try
		{
			double d = double.Parse(newValue);
		}
		catch
		{
			cc.ErrorMessage = "Not a double...";
			e.Cancel = true;
		}
	}
}

Loader.
Live Chat Icon For mobile
Up arrow icon