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
Problems using imap functions
Mail stuck in Lotus oubox
Cheap backlinks? Best bang for the buck SEO site?
Windows Time Issue for 2003 Server
nginx - possible to rewrite based on referring url?
The session setup from computer 'PcName' failed because the security database does not contain a trust account 'PcName$' referenced by the specified computer.
Install Server 2008
Publishing Applications - Windows Server 2008
Limit Files on a Samba Share - Oppisite of veto files
(hopefully) Simple Excel 2007/2010 question