I have this field from the database which is:
DataType: Numeric (7, 3)
So will allow max number
9999.99
Into the database.
I put the number
10.000
Into the database, and now I'm retrieving out of the database using:
<asp:GridView>
I specify:
<asp:BoundField DataFormatString="{0:p}" />
And it outputs
1,000.00%
Which is suppose to be
10.00%
Why isn't it?
I also can't put <% %> server runtime tags into a:
<asp:TemplateField />
Why is this?
Percentages are stored as decimals where 0 = 0% and 1 = 100%. You should store your value as 0.1, not 10.
The line <asp:BoundField DataFormatString="{0:p}" />
will format your value of 10.000 to 1,000.00%.
See here
It's behaving exactly as described in the Standard Numeric Format Strings page on MSDN:
Result: Number multiplied by 100 and displayed with a percent symbol.
So either you shouldn't use that format string, or you should keep your value as a proportion of 1, rather than as a percentage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With