C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

Conversion


Posted Date: 28 Aug 2008      Posted By: Elz      Member Level: Gold     Points: 1   Responses: 6



Hi all
I want to display data in label
actually the data in database is of double type
in label i want data as 4.00
pls help





Responses

Author: sajan    28 Aug 2008Member Level: BronzeRating: 2 out of 52 out of 5     Points: 0

label.Text=Value.ToString{"#,##.00");


Author: sajan    28 Aug 2008Member Level: BronzeRating: 2 out of 52 out of 5     Points: 1

Hi,
use this one
label.Text=Value.ToString("#,##.00");

thanks & Regards,
S.Sajan.



Author: Karthikeyan S    28 Aug 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 4

Since Label.Text is of string datatype and data in database is of double type we have to type cast both things(left side and right side of equation).

So, convert the double value to String datatype using function ToString() so that this value can be set to label's text property.

Following is sample code:

double ldbl = 1.2345;
Label1.Text = ldbl.ToString();



Author: Anil Kumar Pandey    28 Aug 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 5

hi,


u can use the Code like this..

//Calling function to get leave days..
double ldblLeaveDay = getLeaveDay(dtFrom, dtTo);
double ldblLeaveHours = (ldblLeaveDay * 9.5);

lblActual.Text = ldblTotal.ToString().Remove(ldblTotal.ToString().LastIndexOf(".") + 3);
lblAdjust.Text = ( ( Convert.ToDouble(lblActual.Text.ToString()) + ldblLeaveHours ) - (Convert.ToDouble(lblExpected.Text.ToString()))).ToString();


Thanks
Anil

Thanks & Regards
Anil Kumar Pandey



Author: Rajesh Bathala    28 Aug 2008Member Level: SilverRating: 2 out of 52 out of 5     Points: 3

Hi,

for example

Double dbl = 1.456
Label1.Text = Strings.FormatCurrency(dbl, , , TriState.True, TriState.True)

It should work.

Thanks
Rajesh



Author: Rajesh Bathala    28 Aug 2008Member Level: SilverRating: 2 out of 52 out of 5     Points: 3

Hi,

for example

Double dbl = 1.456
Label1.Text = Strings.FormatCurrency(dbl, , , TriState.True, TriState.True)

It should work.

Thanks
Rajesh



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Help Regarding AJAX Controls
Previous : pageload
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use