Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. problem in displaying money in grid view.

problem in displaying money in grid view.

Scheduled Pinned Locked Moved ASP.NET
databasecsshelpquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    souravghosh18
    wrote on last edited by
    #1

    Hi all, In my application i am displaying Amount field in a grid view. which is money type in data base.my problem is when i m displaying it,it shows 4 numbers after decimal like ('45.0000').but i want to display only 2 places after decimal ('45.00').In sql query analyser it shows correctly.I have already used round function but still it is not working. Any suggestions?

    M T 2 Replies Last reply
    0
    • S souravghosh18

      Hi all, In my application i am displaying Amount field in a grid view. which is money type in data base.my problem is when i m displaying it,it shows 4 numbers after decimal like ('45.0000').but i want to display only 2 places after decimal ('45.00').In sql query analyser it shows correctly.I have already used round function but still it is not working. Any suggestions?

      M Offline
      M Offline
      michaelschmitt
      wrote on last edited by
      #2

      Hi there, is it a bound field? Then you could use the DataFormatString property. In a custom/template field, you could output your value as string and use string.Format with a fitting format string (like here).

      S 1 Reply Last reply
      0
      • M michaelschmitt

        Hi there, is it a bound field? Then you could use the DataFormatString property. In a custom/template field, you could output your value as string and use string.Format with a fitting format string (like here).

        S Offline
        S Offline
        souravghosh18
        wrote on last edited by
        #3

        i am using Label to diplay it in a ItemTemplate.

        M 1 Reply Last reply
        0
        • S souravghosh18

          Hi all, In my application i am displaying Amount field in a grid view. which is money type in data base.my problem is when i m displaying it,it shows 4 numbers after decimal like ('45.0000').but i want to display only 2 places after decimal ('45.00').In sql query analyser it shows correctly.I have already used round function but still it is not working. Any suggestions?

          T Offline
          T Offline
          The solution
          wrote on last edited by
          #4

          Please try as below Textbox.Text.ToString("0.00"); Hope this will work for you.

          1 Reply Last reply
          0
          • S souravghosh18

            i am using Label to diplay it in a ItemTemplate.

            M Offline
            M Offline
            michaelschmitt
            wrote on last edited by
            #5

            Hi, then here is an example on how to do it. Just replace the "((double)0.123)" by your variable and modify the rest according to your needs:

            <ItemTemplate>
            <asp:Label runat="server" Text='<%# ((double)0.123).ToString("N") %>'></asp:Label>
            </ItemTemplate>

            G 1 Reply Last reply
            0
            • M michaelschmitt

              Hi, then here is an example on how to do it. Just replace the "((double)0.123)" by your variable and modify the rest according to your needs:

              <ItemTemplate>
              <asp:Label runat="server" Text='<%# ((double)0.123).ToString("N") %>'></asp:Label>
              </ItemTemplate>

              G Offline
              G Offline
              Goutam Patra
              wrote on last edited by
              #6

              it works ,thanx

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups