Input string was not in a correct format.
How to multiply or add two textboxes double typed values?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Dawood AbbasPosted Feb 16, 2015, 12:39 AM
Dawood AbbasPosted Feb 16, 2015, 12:38 AM
public void regCustCalculation()
Dawood AbbasPosted Feb 16, 2015, 12:33 AM
Package Name:
ddlPackName
No. of Extra Connection:
txtNoConn
Charges per Connection(If any):
txtChargeConn
Installation Charges:
txtInstlChrge
Discount (if any):
txtDisc
Amount to Pay:
txtAmntToPay
Paying Amount:
txtPayAmnt
Balance:
txtBlnc
How to get final result1 (txtAmntToPay.text)? and final result2 (txtBlnc)
1).if I select 'ddlPackName' then its price display in 'txtAmntToPay.text'
2).if I enter 'txtNoConn' and 'txtChargeConn' then multiple this both and add with 'ddlpackname' then display in 'txtamnttoPay'
if I not select 'ddlpackname' then display multiplied values.
3).like this all textboxes values add with 'txtPayAmnt' and subtract 'txtDisc'
Khargesh RajputPosted Feb 13, 2015, 6:44 AM
use convert in uppercase with c
Jignesh TrivediPosted Feb 13, 2015, 6:44 AM
Hi,
here Textbox1.text and textbox2.text is your textbox value.
also double.tryparse function return 0 if function is fail to convert value to double.
Please refer below link for more information.
https://msdn.microsoft.com/en-us/library/3s27fasw(v=vs.110).aspx
can you please share textbox value?
Dawood AbbasPosted Feb 13, 2015, 6:38 AM
like below
double does not contain a definition for 'Text' and no extension methode 'Text accepting a first argument of type 'double' could be found (are you missing a using directive or and assemble reference?)
I tried alredy and also like below
double amount =convert.ToDouble(txtamount.Text);
here also showing same above error message.
Jignesh TrivediPosted Feb 13, 2015, 6:31 AM
Hi,
Textbox always contains string value so you have to cast this value to double.
try this....
double number;
double number1;
Double.TryParse(Textbox1.Text, out number);
Double.TryParse(Textbox2.Text, out number1);
double sum = number+number1;
hope this will help you.