I tried
try
{
Template.Close(true);
}
catch
// Handle Exception which it never hits
I also tried
Grid.UpdateData
// again not hit
I have a dataset associated to the grid and as soon the Grid.UpdateData (or Template.Close(true) causes the grid to do an UpdateData to the datasource) it gives an error which does not appear to be trappable through try catch block. The problem is the data in the RowEdit Template is invalid and causes a constraint violation. I am not concerned about the violation, I want to catch the violation and handle it on the template close gracefully. Is there a way of knowing before a template close or updatedata that there is a violation or capturing the violation?
private void ultraButton2_Click(object sender, EventArgs e) { bool success = ultraGridRowEditTemplate1.CommitChanges(); if (false == success) return; try { ultraGridRowEditTemplate1.Close(true); } catch { } }
Run app and enter say ABC on consecutive rows to create a unique key violation.
Before calling ultraGridRowEditTemplate1.Close(true); - I would like to see if it is going to cause an error or to trap the error on the call.
What is best way of trapping the error (ideally would like to pre-test the close and if in error - display the error and then cancel the close)?
Hi,
The error is most likely being caught by the grid and raised to you as an event.
Try handling the Error and/or CellDataError event of the grid and see if they fire when the error occurs.
Hello,
Could you please try to attach if possible a small sample project reproducing the above mentioned issue, I will be happy to take a look at it.
Please do not hesitate to contact us if you need any additional assistance.