i am working in forms and in database its type is double and i want convert in text.
1: I have a double value as below
public double? Area {get; set;}
2:
string v = txtTarget.ToString();
Form.Area = v;
I am using this way but not works
i am working in forms and in database its type is double and i want convert in text.
1: I have a double value as below
public double? Area {get; set;}
2:
string v = txtTarget.ToString();
Form.Area = v;
I am using this way but not works
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Naimish MakwanaRank #324 · 7.7K reputationPosted Jan 24, 2023, 5:26 AM EST
Your property type is double, so you need to convert v to double.
Thanks
Amit MohantyRank #112 · 20K reputationPosted Jan 24, 2023, 5:28 AM EST
To convert a string to a double using the
double.Parse()ordouble.TryParse()method.Vishal JoshiRank #377 · 6.7K reputationPosted Jan 24, 2023, 6:07 AM EST
Hello Garima,
To Convert Text box value to double please try below code.
As you mention Area as nullable, ToString() will not work. in this case you should try Convert.ToString(). or you can check String.IsNullOrEmpty(String).
Try the below code.
Also, review the below link for ToString vs Convert.ToString:
https://www.c-sharpcorner.com/blogs/converttostring-vs-tostring-in-c-sharp1
Thanks
Sachin SinghRank #66 · 26.2K reputationPosted Jan 24, 2023, 6:19 AM EST
Two changes,
Form.Area= Convert.ToDouble(txtArea.Text) ;
second
when in your code behind get the value as
Form.Area.Value