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
close icon

Custom Type Conversion Validation

Hi, I have a question concerning custom type conversion validation. I do not want to have the grid display the messages "x is not a valid value for type y" I want to have it display some more meaningful/understandable messages in the form of " You have supplied an invalid input. x is not a valid Number " At the moment I have it implemented using an override for the grid's OnCurrentCellValidating actually mimicing the functionality implemented in GridCellRendererBase.cs that way that I call up GridCellValueConvert.Parse and then throwing appropriate exceptions for all the CellValueTypes I want to be able to deal with. This is, somehow, redundant. If there was a way to plug in some message supplier for the standard validation routines, I would be very happy. Thanks for your help. Regards Kai Iske DWS Investments

5 Replies

AD Administrator Syncfusion Team February 21, 2003 12:39 PM UTC

Hi Kai, The problem you describe is quite common and we will offer more customization for parsing values in future version. There will be an event then that lets you hook in before the value gets converted to the result type. Stefan


AD Administrator Syncfusion Team January 20, 2004 07:41 PM UTC

Hi, I am running into same problem with the error messages in my DataBound grids (Syncfusion 1.6.1.8/VS.NET 2003/XP). Is there any way to intercept the errors (and/or exceptions) and show my own user friendly messages when incorrect data is entered into dates, int and decimal fields? An example of how to go about doing this at a cell level would be great. thanks, - Reddy


AD Administrator Syncfusion Team January 20, 2004 07:56 PM UTC

If you want to do the validation yourself, you can handle CurrentCellValding and set the message there. pre> private void gridDataBoundGrid1_CurrentCellValidating(object sender, CancelEventArgs e) { GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; if(!cc.Renderer.ControlText.StartsWith("r")) { e.Cancel = true; cc.ErrorMessage = "Must start with r"; } } If you catch the ValidateFailed event, you can just set the message. private void grid_ValidateFailed(object sender, GridValidateFailedEventArgs e) { e.Handled = true; GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; cc.ErrorMessage = "SomeMessage"; }


AD Administrator Syncfusion Team January 20, 2004 08:06 PM UTC

Clay, In our application we allow dates from 1/1/1901 to 12/31/9999. If I enter 1/1/10000, grid is giving a popup window "Valid values are between 1 and 9999, inclusive. Parameter name:year". If I type "abc" into a date cell, grid shows an error "The string was not recognized as a valid DateTime. There is a unknown word starting at index 0." Similarly, if I enter "abc" into an integer column it gives some error dialog on its own. Business users will have no clue about what we are talking about in these error dialogs, unless we give them a user fiendly error messages. I already have this CurrentCellValidating event handler attached. I am not getting a chance to handle this kind of errors in the event handler. thanks, - Reddy


AD Administrator Syncfusion Team January 20, 2004 09:17 PM UTC

Are you in a GridDataBoundGrid? If so, try catching the ValidateFailed event, and set the CurrentCell.ErrorMessage at that point. As far as the CurrentCellValidating, is it being hit prior to the display of the messages you mentioned above. If so, if you directly validate the string (not relying on the grid to do so) in CurrentCellValidating, and then you can set CurrentCell.ErrorMessage to display a custom message. Here is a little sample that requires you to enter an integer, and displays a custom message if you do not.

Loader.
Live Chat Icon For mobile
Up arrow icon