Quick note:
I'm retrieving a money value from a sql server 2005 database. When walking through the reader, I want to display the dollar amount formatted correctly. But, it keeps coming up incorrect. For example: 200.00000 instead of $200.00.
Solution:
I was looping through the reader, converting the value to a string then trying to format it. I took out the .toString() and it worked fine.
correct usage:
String.Format("{0:c}",reader["dollarvalue"])
Also, if we are prefilling a text box, we do not want to show the $ sign. So, we use a different format:
String.Format("{0:f}", reader["dollarvalue"])
No comments:
Post a Comment