How to format a decimal field to show thousand separators

Last post 07-21-2009 12:45 PM by snufse. 2 replies.

Sort Posts:

  • How to format a decimal field to show thousand separators

    07-20-2009, 4:31 PM
    • Member
      31 point Member
    • snufse
    • Member since 11-15-2006, 3:54 PM
    • Posts 93

     I am formating a variable like this:

    Dim AC2_Gross_Qty As Decimal = Format("0.00")

    Is there a way to say that I want to see the thousand separators when displayed (in a footer gridview)

  • Re: How to format a decimal field to show thousand separators

    07-20-2009, 5:04 PM
    Answer
    • Member
      117 point Member
    • goldbishop
    • Member since 10-18-2006, 1:46 AM
    • Tuscaloosa
    • Posts 53

     Well, for one you dont have the correct format for the string....try this (it may not be syntactically correct but should get you started)

    dim AC2_Gross_Qty as Decimal = ctype(string.format("{0:9,990.00}", 0.00), Decimal)


     

    You see the ant....I am the ant....I take you to my queen!
  • Re: How to format a decimal field to show thousand separators

    07-21-2009, 12:45 PM
    • Member
      31 point Member
    • snufse
    • Member since 11-15-2006, 3:54 PM
    • Posts 93

     I added this to the Boundfield.DataFormatString = {0:#,0.00} that took care of the cell format now showing thousand separator.

    My GriedView footer (sum of all cells) still shows the number with 2 decimals without the thousand separator. I am trying to figure out why. Here is the code for accumulating the cells and showing the footer:

    Dim AC2_Gross_Qty As Decimal = CType(String.Format("{0:#,0.00}", 0.0), Decimal)
    If mySqlDataTable.Rows.Count > 0 Then
                For i As Integer = 0 To mySqlDataTable.Rows.Count - 1
                    AC2_Gross_Qty = AC2_Gross_Qty + mySqlDataTable.Rows(i).Item("ac2_gross_qty")
               Next
    End If
     
    Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowCreated
    
           If e.Row.RowType = DataControlRowType.Footer Then
                e.Row.Cells(3).Text = "Selection Total  "
                e.Row.Cells(4).Text = Session("ac2grossqty")
           End If
    End Sub


     

Page 1 of 1 (3 items)