Hi,
I have an ultragrid whose column's editor is set to a something that inherits from EmbeddableImageRenderer.
I have overrided the GetAutoConvertedDestinationValue() method. The sourceval Object is computed by us and sent to the base method.
It looks this way.
Return MyBase.GetAutoConvertedDestinationValue(direction, App.GetAutoConvertedDestinationValue(Me, direction, sourceVal, owner, ownerContext, isValidConversion), destinationType, isValidConversion, owner, ownerContext)
SourceVal computing part throws an exception. What is the best way to handle this?
We tried setting column error and tool tip text to show the error message. Another method we tried was sending IsValidConversion false. But then user wont know why image does not show. Is there a more elegant way to do this?
Thanks
Sowmya
That's tricky.
I probably wouldn't rely on the editor to set the ColumnError. That seems like a bad idea. Typically, you use the InitializeRow event to validate the cell data and show an error. The editor code is going to get hit a LOT more often then you really need in order to indicate an error. So I wonder if you could somehow separate the validation code from the code that creates the image and do it that way. I can't really be sure that would make a big difference. But I am sure that having the editor throwing (and catching) an exception is something that I would try to avoid any way you possibly can, because that's going to be really bad in terms of performance.
Yes, you are right. The code that is trying to convert the sourceValue into an image is raising an exception. Yes, we have Try Catch block there and we are setting ColumnError which slows down the system. Showing the message is also tedious since this event gets fired frequently. We want to try to avoid an exception but say it anyways happens, is there internally in Infragistics which can indicate the error for column?
I'm not really sure I understand the issue. Are you saying that your code that is trying to convert the sourceValue into an image is raising an exception? Generally speaking, you should try to avoid that if at all possible. The renderer is going to get hit every time a cell in that column paints, which happens a LOT. And an exception, even if handled, will cause a serious performance hit. If the exception is unavoidable, then all you really need to do is make sure you wrap a try...catch around it so it doesn't blow up the application. Presumably you are already doing that because otherwise I don't really understand what you mean about wanting the cell to still show an image, even when it blows up. Returning false indicates that the value of the cell could not be converted to the proper type, so that's why the image does not display in that case.
Hello and thank you for contacting Infragistics.
At this time we will require a sample application that demonstrates and isolates the behavior as this issue is not known to us. If you have any additional questions or concerns feel free to let me know.