Skip to content

ultranumericeditor null value

New Discussion
Francois
Francois asked on Mar 15, 2017 8:53 PM

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.

Sign In to post a reply

Replies

  • 0
    Christopher Shea
    Christopher Shea answered on Mar 15, 2017 8:53 PM

    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.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Francois
Favorites
0
Replies
1
Created On
Mar 15, 2017
Last Post
9 years, 7 months ago

Suggested Discussions

Tags

No tags

Created by

Created on

Mar 15, 2017 8:53 PM

Last activity on

Mar 15, 2017 8:53 PM