Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42220

VS 2010 Custom Currency/Decimal Format

$
0
0
I have searched and found various methods for formatting as a string decimal values but cant fine one which covers all my needs.

I have to display a decimal value (a financial money figure) i.e. 2500.75

However I do not require any leading currency symbol such as $ or £
and the main point I am struggling with is that when the value has no value after the decimal do not display zeros.

I thought
Code:

.ToString(".##")
was meeting my requirements initiall but then realized if someone put the value 7.4 in it was displayed as 7.4 when it should be displayed as 7.40.

I have also tried
Code:

<%# String.Format("{0:0.##}", DataBinder.Eval(Container.DataItem, "Amount"))%>
But this seems to have no effect at all.

And in addition
Code:

<%# String.Format("{0:0.C}", DataBinder.Eval(Container.DataItem, "Amount"))%>
always displays the two decimals even when zero.

Viewing all articles
Browse latest Browse all 42220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>