Results 1 to 2 of 2

Thread: [RESOLVED] Custom Currency/Decimal Format

  1. #1

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Resolved [RESOLVED] Custom Currency/Decimal Format

    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.

  2. #2

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Re: Custom Currency/Decimal Format

    this seems to work

    this.txtAvailableFunds.Text = (String.Format("{0:0.##}", applicant.AvailableFunds).Contains('.')) ? (String.Format("{0:0.00}", applicant.AvailableFunds)) : (String.Format("{0:0.##}", applicant.AvailableFunds));

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width