Click here to Skip to main content
15,898,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am storing values in SQL Database table as floating point. But i dont need a long floating number, just want to display it in two decimal places. Thanks
Posted
Comments
Dharmendra-18 27-Feb-13 5:59am    
to display up two two decimal place you can use ToString("0.00");
like this
lblvalue.Text=(Convert.ToDouble(dr["vals"].ToString())).ToString("0.00");

Try to use decimal data type[^] like this decimal(5, 2) for range <-999.99, +999.99>.
 
Share this answer
 
Hi
Convert it to two decimal points when you fetch data from database as follows

SQL
SELECT Col1, Col2, CAST(Col3 AS DECIMAL(18,2)) AS Col3 FROM TABLE1


Or

You have to convert in your code behind.
C#
Math.Round(YourValue, 2).ToString();
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900