Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2490
ultranumericeditor null value
posted

Hi, 

I use ultranumericeditor with Nullable = true

When I erase all data, I can't assign my property because the value is not NULL is System.DBNull

_Quote.NumberDeliveryDays = (int?)uneNumberDeliveryDays.Value;

I have error 'System.InvalidCastException'

What is the best way to assign my property to NULL ?

Francois.

Parents
No Data
Reply
  • 6158
    Verified Answer
    Offline posted

    Hello Francois.

    It is intentional that the UltraNumericEditor's Value property returns DBNull when the edit area is empty. This was most likely done to support binding to the Value property.  You should be able to work around this using a simple DBNull check:

    _Quote.NumberDeliveryDays = this.uneNumberDeliveryDays.Value == DBNull.Value ? (int?)null : (int)this.uneNumberDeliveryDays.Value;

    Additionally if there are numerous places where this scenario would be encountered, you could get around the issue using a DataFilter. This forum post gives details regarding a DataFilter of this nature.

    Let me know if you have any questions.

Children
No Data