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
Windows Authentication with User and Roles management in SQL Server
Screen Printing / Art Department Resource Scheduling and Organization
jquery
Deploy RemoteApp MSI using GPO
Block access to a single website - Software Resttriction Policies
ShellExecute while remaining in process
Create Table (MS SQL 2008) with Time Column that accepts 14:00 format only
How to allow/disallow with robots.txt a specific directory
Server Recommendation (File Server & Terminal Server)
access 2003: subreport not hiding controls