ASP.NET 2.0 GridView DataFormatString for Amounts (SqlMoney)
I might have discussed this in my blog earlier. However I will like to share my thoughts again.
Check this:
http://community.sgdotnet.org/photos/chuawenching/picture44026.aspx
As you can see, if I don't set the DataFormatString (don't forget to set HtmlEncode="false"), I will get the 1st picture. Why 0.0000 instead of 0.00? Read my earlier posts :)
Since Amount should display the currency values like $0.00 instead of 0.0000. So you should format it as {0:C} or {0:c}. Take note, there is no use if you try this {0:C2}.
You will get your results as you want. Assuming it is based on en-US okay :)
But there are times when customer asks you to place the currency itself that gridview column HeaderText like this "Amount (RM)". RM represents the currency in Malaysia. So there is no point display $0.00.
For DataFormatString on currency, I can't see a way to remove the dollar sign '$'. So to do that, you have to format it to decimal like in 3rd picture using {0:#,##0.00}
Like this, it looks more reasonable and customer will be happy.