Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 ....
 
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 28-Jan-13 2:06am
v2
Comments
Gittu Dash at 28-Jan-13 8:34am
   
I think 'Convert.ToDouble' should work.
Are you sure it's not working ??
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi Sandeep,
 
Check out the following example:
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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 693
1 George Jonsson 345
2 BillWoodruff 337
3 Sergey Alexandrovich Kryukov 244
4 Garth J Lancaster 240
0 Sergey Alexandrovich Kryukov 10,764
1 Maciej Los 5,474
2 OriginalGriff 5,472
3 CPallini 3,819
4 BillWoodruff 3,594


Advertise | Privacy | Mobile
Web03 | 2.8.141030.1 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100