RadNumericTextBox - server side value

3 posts, 1 answers
  1. Cory
    Cory avatar
    22 posts
    Member since:
    Sep 2015

    Posted 19 Oct 2015 Link to this post

    Hi - I've been searching for a way to do this but haven't found the "correct" way.


    I have a RadGrid - on it are multiple RadNumericTextBox columns - one of those columns is txtQTY.

     In the save form logic I need to get the value of that column from each of the records in the rad grid to build a table of values to pass to the database.  All that worked fine back in VS 2003.  I did the following back then:

     double X

    x = ((RadNumericTextBox)(this.raddgActivityGroup.Items[i]).FindControl("txtQTY")).Value;

     But in this version VS 2013 and newest telerik AJAX controls - I get the following problem:

    Error 271 Cannot implicitly convert type 'double?' to 'double'. An explicit conversion exists (are you missing a cast?) 

    I can get rid of the problem by changing the line to read:

     x = ((RadNumericTextBox)(this.raddgActivityGroup.Items[i]).FindControl("txtQTY")).Value.Value;

    but I have no idea why that works and am very concerned that I might be breaking something.






  2. Answer
    Konstantin Dikov
    Konstantin Dikov avatar
    2406 posts

    Posted 22 Oct 2015 Link to this post

    Hi Cory,

    The error that you are receiving is due to the fact that the Value property of the RadNumericTextBox will return nullable double (double?), so your "x" variable should be a double? type:
    double? x = RadNumericTextBox1.Value;

    If you want to keep the "x" variable as double you can use the following line, which will return 0 if the value of the RadNumericTextBox is null:
    double test = RadNumericTextBox1.Value != null ? (double)RadNumericTextBox1.Value : 0;

    And here is a link to MSDN article about nullable types:
    Hope this helps.

    Konstantin Dikov
    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
  3. Cory
    Cory avatar
    22 posts
    Member since:
    Sep 2015

    Posted 27 Oct 2015 in reply to Konstantin Dikov Link to this post

    Awesome customer service Konstantin!  Thanks for the help!



Back to Top