GridView: Formatting doesn’t apply on "Money" data type using DataFormatString


Today, I was trying my hands with GridView. It was a very simple ASP.NET page where I was displaying Products in a grid. The Product Table has a column “Price” of “Money” Db Type. When I was fetching the data in the grid, I was getting the format as “0.0000”. Since none of my products require more that 2 decimal places, i tried all the combination with DataFormatString like “{0:f2}” or “{0:C}” . At last I found the solution, I turned “HTMLEncode” to Off and then the DataFormatString started its magic.


It worked.