Bind to nullable values

4 posts, 0 answers
  1. Anton
    Anton avatar
    8 posts
    Member since:
    Aug 2014

    Posted 18 Dec 2015 Link to this post

    Hello. I tried to bind RadNumericBox to a nullable property and after that the control was not sending any value updates to the property. How could I fix it?

     

    Thanks

  2. Anton
    Anton avatar
    8 posts
    Member since:
    Aug 2014

    Posted 18 Dec 2015 in reply to Anton Link to this post

    Property type is short?/decimal?. Everything works fine when I replace these types to short/decimal or to double?.
  3. Ivaylo Gergov
    Admin
    Ivaylo Gergov avatar
    661 posts

    Posted 23 Dec 2015 Link to this post

    Hi,

    Thank you for your interest.

    We will further investigate this issue and I will get back to you as soon as we have any information.

    Regards,
    Ivaylo Gergov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  4. Ivaylo Gergov
    Admin
    Ivaylo Gergov avatar
    661 posts

    Posted 28 Dec 2015 Link to this post

    Hi,

    The RadNumericBox.Value property is of type double? and while the framework can handle the conversion between double? and int for example(RadNumericBox by default handles the conversion between your data type to double?), this is not the case with decimal. In this case you will need a converter tho convert from double? to the desired type.
    Here's an example:

    public class CConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            return value;
        }
     
        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            var decimalValue = System.Convert.ToDecimal(value);
     
            return decimalValue;
        }
    }

    Let me know should you need further assistance.

    Regards,
    Ivaylo Gergov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top