DataFormatString="{0:F2}" in my ascx page for value 0.0001 results in “0.00” and what I need is “0.01“, that is rounding away from zero. Is it possible to achieve in asp.net with DataFormatString or should I use some custom rounding method?
DataFormatString={0:F2} in my ascx page for value 0.0001 results in 0.00 and what I
Share
You cannot achieve this by any kind of rounding. 0.0001 in 2 digits will always become 0.00 .
If you really want this you’ll need to write a conversion method. Write out the specs first.
DataFormatString suggests a data-bound control so you may need an extra (computed) column with something like
r = (v < 0.01 && r > 0.0) ? 0.01 : v;