Microsoft
Software
Hardware
Network
Question : String.Format not working when using Label Text
I have the following code which I am using to display calculated averages into various labels. When I use the String.Format to control the display of decimal places it has no effect and displays numbers with several numbers to the right of the decimal point.
Example. It will display 266.167689999999 where I want it to only display 266.17
Here is the code to populate the Labels:
//***** divide Total by count to get average ********
decimal lodgingAdvAvg = lodgingAdvTotal / lodgingAdvCount;
//****** Display Results on Label Text and format to 2 decimal points ***********
lblLodgingAdv.Text = String.Format("{0:d}", lodgingAdvAvg.ToString());
Answer : String.Format not working when using Label Text
try this in between:
Math.Round(lodgingAdvAvg,2
);
Random Solutions
DReamwever how to link pages.
New mail notification envelope icon in outlook 2003 doesn't show
Check if existing record in database?
Sharepoint Foundation 2010 Wizard cannot connect to database master
w32time
vfp grid number format with commas set decimals
Have a 4700 printer and would like to configure it to only print in black and white.
vCenter Converter and SBS2008
How do I set up a link to a specific page within a wordpress template?
Double Table when margin is adjusted