Click here to Skip to main content
15,895,827 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to display decimal(10,2) value with comma separated with only 2 digits after decimal point.
i have tried following code in view model comma separated is working but it is displaying 4 digits after decimal point e.g value=1,000.0000 i want value=1,000.00
//code
[DisplayFormat(DataFormatString = "{0:0,0.0,0.0}")]
Posted

A C# example for you...
C#
decimal nDec = 123456789.1234M;
string szDec = string.Format( "{0:#,#.00}", nDec );

It gives 123,456,789.12...
 
Share this answer
 
Comments
Abhinav S 19-Mar-14 4:32am    
That is correct. 5.
Kornfeld Eliyahu Peter 19-Mar-14 4:44am    
Thank you :-)
Your format string should be:
"{0:#,0.00}"
 
Share this answer
 
v2
Comments
Member 9579525 19-Mar-14 5:14am    
still it is displaying 4 digit after decimal point
Member 9579525 19-Mar-14 6:54am    
now this is working...thank you
Raul Iloc 20-Mar-14 2:18am    
Welcome!

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