Hi Everyone, i have one Gridview in my .aspx page.i am showing dynamic data in this grid.how i will show the float or double number in 2 decimal places in gridview.
thanks in advance
Hi Everyone, i have one Gridview in my .aspx page.i am showing dynamic data in this grid.how i will show the float or double number in 2 decimal places in gridview.
thanks in advance
The bound column should have a DataFormatString column. You could do something like:
DataFormatString="{0:0.00}"
Numeric Custom Format Strings
UPDATE
In the case of AutoGenerateColumns="true"
... I'd have to know more specifics about what you're binding, but here are some avenues to explore:
There are two easy ways to format things in a GridView. The first is given in a previous answer - use the DataFormatString. The second, which sounds like it applies to your situation, where you are dynamically loading the grid, is to change the data going into the grid.
So, rather than returning a number and trying to format it, return a formatted number and let the GridView display it.