This is a migrated thread and some comments may be shown as answers.

RadNumericTextBox - server side value

2 Answers 153 Views
Input
This is a migrated thread and some comments may be shown as answers.
Cory
Top achievements
Rank 1
Cory asked on 19 Oct 2015, 08:30 PM

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.

 

HELP!?!?

 

Thanks

Cory

2 Answers, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 22 Oct 2015, 11:16 AM
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.


Regards,
Konstantin Dikov
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
0
Cory
Top achievements
Rank 1
answered on 27 Oct 2015, 07:42 PM

Awesome customer service Konstantin!  Thanks for the help!

 

Cory

Tags
Input
Asked by
Cory
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Cory
Top achievements
Rank 1
Share this question
or