Click here to Skip to main content
15,881,843 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hai Guys
I have one doubt in c#.net +asp.net webservices , I have three text boxes like this
Textbox1 EmpId only Int like 123
TextBox2 Empname only String likes sandeep, Miriyala,
TextBox3 EmpSalary only double like 6543.50 paise follows
I have one doubt while submiting buttion

Webservices will collected

My webservices is as follows

EmpId->TextBox1.value
EmpName->TextBox2.value
EmpSal->TextBox3.value
what are the user will entered the textbox I am sending to webservices method My webservices method is as follows..
I know that By default value in asp textboxes enter by user is String format only is it requied to convert again and again in my webservices ....

C#
protected string  AddDetails(int EmpId, String  Empname, Double Empsal)
{

String FinalResult;
FinalResult=Convert.ToInt32(EmpId)+Empname+Convert.Todouble(Empsal);
return FinalResult;
}


Is it required to convert the textboxes values to String if it is required How to convert Double datatype to String datatype Gave me some basic example I am facing some problem converting the double to string , Please help me.


Thanks& Regrads
Sandeep Miriyala
Posted
v2
Comments
P_Dash 28-Jan-13 8:34am    
I think 'Convert.ToDouble' should work.
Are you sure it's not working ??

Hi Sandeep,

Check out the following example:
C#
string FormattedSalary = Empsal.ToString("C2"); 

will convert your salary field to a string representing a currency value e.g.:
if Empsal = 6346.47231
you will get: "$6346.47" (according to the localization of course)

Cheers,
Edo
 
Share this answer
 
I got the solution By default HTML Textbox take it as String data type, that reason, I can changed method, String data type. I changed the method is as follows, according to my point of view it is correct


protected string AddDetails(String EmpId, String Empname, String Empsal)
{

String FinalResult;
FinalResult=EmpId+Empname+Empsal;
return FinalResult;
}

here no needed to typecast the double to string , int to string.
Thanks &Regrads
Sandeep M
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900