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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. data formatting expression

data formatting expression

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
6 Posts 2 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.
  • M Offline
    M Offline
    Member 3879881
    wrote on last edited by
    #1

    Hi i am doing some calculation & getting values in decimal..., And i am displaying it in datagrid, in that datagrid columns "data formatting expression" i given as {0:N} Like..., So in that columns,after the decimal i am getting 2 values only..., I tried to store the values in my table..., But its store my first value only..., It Means,its store all row values...,But the value first number only store in the table..., Example value will be 510.01 means...,in table its store only 5..., If i remove the {0:N} "data formatting expression".., then its store the full value like 510.0123..., Whats the probs?, y if i give "data formatting expression" its not store properly..., Anyone solve my probs...,

    Magi

    A 1 Reply Last reply
    0
    • M Member 3879881

      Hi i am doing some calculation & getting values in decimal..., And i am displaying it in datagrid, in that datagrid columns "data formatting expression" i given as {0:N} Like..., So in that columns,after the decimal i am getting 2 values only..., I tried to store the values in my table..., But its store my first value only..., It Means,its store all row values...,But the value first number only store in the table..., Example value will be 510.01 means...,in table its store only 5..., If i remove the {0:N} "data formatting expression".., then its store the full value like 510.0123..., Whats the probs?, y if i give "data formatting expression" its not store properly..., Anyone solve my probs...,

      Magi

      A Offline
      A Offline
      ash04
      wrote on last edited by
      #2

      Using the data formatting expression does not cause the problem like this. I think it is related with your Database code. Please check it or give the details about the method you are using to save the data into database.

      DAsh04

      M 1 Reply Last reply
      0
      • A ash04

        Using the data formatting expression does not cause the problem like this. I think it is related with your Database code. Please check it or give the details about the method you are using to save the data into database.

        DAsh04

        M Offline
        M Offline
        Member 3879881
        wrote on last edited by
        #3

        See in datadrid i am getting values in that column like..., Col1 510.09 234.78 12344.76 Values for with in datagrid so i try to store those value in this format(my add button click event) For Each MainGRD As DataGridItem In Me.dgrdsub.Items sqlconn.Open() Dim strInsertproc As String Dim GTotal As Decimal = Val(MainGRD.Cells(3).Text) Dim BonusAmt As Decimal = Val(MainGRD.Cells(5).Text) Try strInsertproc = "BonusAdd'" & GTotal & "','" & BonusAmt & "'" sqlCmd = New SqlCommand(strInsertproc, sqlconn) sqlCmd.ExecuteNonQuery() lblMessage.Text = "Record Inserted............" Catch ex As Exception If Mid(ex.Message, 1, 9) = "Violation" Then lblMessage.Text = "Already exist in the DataBase......" Else lblMessage.Text = Mid(ex.Message, 1, 75) ' Show friendly error message. End If End Try sqlconn.Close() In that col1 if i give {0:N} then the values store in my table like: 5 2 1 If i remove the data formatting expression {0:N} then the values store in my table like: 510.09010 234.787778 12344.766576

        Magi

        A 1 Reply Last reply
        0
        • M Member 3879881

          See in datadrid i am getting values in that column like..., Col1 510.09 234.78 12344.76 Values for with in datagrid so i try to store those value in this format(my add button click event) For Each MainGRD As DataGridItem In Me.dgrdsub.Items sqlconn.Open() Dim strInsertproc As String Dim GTotal As Decimal = Val(MainGRD.Cells(3).Text) Dim BonusAmt As Decimal = Val(MainGRD.Cells(5).Text) Try strInsertproc = "BonusAdd'" & GTotal & "','" & BonusAmt & "'" sqlCmd = New SqlCommand(strInsertproc, sqlconn) sqlCmd.ExecuteNonQuery() lblMessage.Text = "Record Inserted............" Catch ex As Exception If Mid(ex.Message, 1, 9) = "Violation" Then lblMessage.Text = "Already exist in the DataBase......" Else lblMessage.Text = Mid(ex.Message, 1, 75) ' Show friendly error message. End If End Try sqlconn.Close() In that col1 if i give {0:N} then the values store in my table like: 5 2 1 If i remove the data formatting expression {0:N} then the values store in my table like: 510.09010 234.787778 12344.766576

          Magi

          A Offline
          A Offline
          ash04
          wrote on last edited by
          #4

          Hi, have you checked what is being stored in the variables "GTotal" and "BonusAmt" during the program execution.

          DAsh04

          M 1 Reply Last reply
          0
          • A ash04

            Hi, have you checked what is being stored in the variables "GTotal" and "BonusAmt" during the program execution.

            DAsh04

            M Offline
            M Offline
            Member 3879881
            wrote on last edited by
            #5

            ya i checked if i give data formatting expression{0:N} Then first value..,first number only i am getting..., If i remove that format exp then i am getting correct value...,

            Magi

            A 1 Reply Last reply
            0
            • M Member 3879881

              ya i checked if i give data formatting expression{0:N} Then first value..,first number only i am getting..., If i remove that format exp then i am getting correct value...,

              Magi

              A Offline
              A Offline
              ash04
              wrote on last edited by
              #6

              Hi, Format does not cause error like this. Please check the variables' value after statement like Dim GTotal As Decimal = Val(MainGRD.Cells(3).Text) Dim BonusAmt As Decimal = Val(MainGRD.Cells(5).Text) and check your stored procedure "BonusAdd" and its parameter type and width.

              DAsh04

              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