Solved

Replace comma to dot when SQL is loaded.

Posted on 2002-03-15
2
1,620 Views
Last Modified: 2010-08-05
Hi Experts.

I use aspgrid from www.aspgrid.com
Object reference below:
http://www.aspgrid.com/objectreference.html

I will post the code below my explanation.

I have problems with commas and dots.
When I store a value using a dot in a field
in the aspgrid and then save the record is
turned into a comma.

Example:

12.1 become 12,1

The datatype for the table field is float.

The real proble is if I click on the edit button
and want to change a value in a record I must
cahnge all commas to dots again.

If I should ignore my validation code and store the value
in the form as 12,1 it turns to 121
Therefore I must use a dot before my decimals.

So the solution must be to display replace the commas to dots when pressing on the edit button.

I have tried several solutions but none fo them works.

Really need some expert help here.

THANKS IN ADVANCE.






----------------------------------------------
<HTML>
<HEAD>
<TITLE>AspGrid 3.0 Demo - Expense Report</TITLE>


<SCRIPT LANGUAGE="JavaScript">
function Validate()
{
      
      if( isNaN(document.AspGridFormSave1.FIELD5.value ) )
      {
            alert('Not a number.');
            document.AspGridFormSave1.FIELD5.focus();            
            return false;
      
      }
      if( isNaN(document.AspGridFormSave1.FIELD6.value ) )
      {
            alert('Not a number.');
            document.AspGridFormSave1.FIELD6.focus();
            return false;
      }
      if( isNaN(document.AspGridFormSave1.FIELD7.value ) )
      {
            alert('Not a number.');
            document.AspGridFormSave1.FIELD7.focus();
            return false;
      }
      if( isNaN(document.AspGridFormSave1.FIELD8.value ) )
      {
            alert('Not a number.');
            document.AspGridFormSave1.FIELD8.focus();
            return false;
      }
      
      if( document.AspGridFormSave1.FIELD5.value == "")
      {
            alert('Field is empty.');
            document.AspGridFormSave1.FIELD5.focus();
            return false;
      }
      if( document.AspGridFormSave1.FIELD6.value == "")
      {
            alert('Field is empty.');
            document.AspGridFormSave1.FIELD6.focus();
            return false;
      }
      if( document.AspGridFormSave1.FIELD7.value == "")
      {
            alert('Field is empty.');
            document.AspGridFormSave1.FIELD7.focus();
            return false;
      }
      if( document.AspGridFormSave1.FIELD8.value == "")
      {
            alert('Field is empty.');
            document.AspGridFormSave1.FIELD8.focus();
            return false;
      }
            
      
      return true;
}
</SCRIPT>


<body bgcolor="#FFFFFF">
<p><b>Op-register v0.0.1</b><br>
  <%
            
      ' Create an instance of AspGrid
      Set Grid = Server.CreateObject("Persits.Grid")
            
      ' Specify location of button images
      Grid.Imagepath = "aspgrid/images/"
   
      ' Specify SQL statement. We store session IDs to allow simultaneos users to run the demo transparently
      Grid.SQL = "select id, sessionid, Productid, OpLocationid, InternalTime, InternalYield, CustomerTime, CustomerYield, EditedDate from OpRegister WHERE Productid= '"&Cstr(session("sessProductid"))&"' ORDER BY id"

      ' Connect using a DSNless connection string
      ConnectStr = "Provider=SQLOLEDB;Server=madeleine;Database=Operationsregister;UID=sa;PWD="
      Grid.Connect ConnectStr, "", ""
      
      ' Optional: specify a client-side JavaScript validation routine
      Grid.FormOnSubmit = "return Validate();"

      ' Use POST rather than GET
      Grid.MethodGet = False
          
      ' specify <TABLE> attributes of the grid
      Grid.Table.CellSpacing = 0
      Grid.Table.CellPadding = 0
      Grid.Table.Width = 600

      ' Hide the ID and SESSIONID columns
      Grid.ColRange(1, 3).Hidden = True

      ' specify the default value for the hidden SESSIONID column
      Grid.Cols("sessionid").DefaultValue = Session.SessionID
          
      Grid.Cols("Productid").DefaultValue = Cstr(session("sessProductid"))
      
      Response.write "Product:<font color=""red""><b>" & Cstr(session("sessProductid")) & "</b></font><br>"
      
      ' Enable control buttons at both sides of grid
      Grid.ShowLeftSideButtons

      ' Set header captions      
      Grid("OpLocationid").Caption = "Location"
      Grid("InternalTime").Caption = "Tid1"
      Grid("InternalYield").Caption = "Yield1"
      Grid("CustomerTime").Caption = "Tid2"
      Grid("CustomerYield").Caption = "Yield2"
      Grid("EditedDate").Caption = "Date"

      ' Set column width
      Grid.Cols(0).Header.Width = 35
      Grid.Cols(0).Cell.Width = 35
      Grid.Cols(0).Cell.NoWrap = True

      ' Columns 1, 2 and 3 (id, sessionid and Productid) are hidden
      
      Grid.Cols(4).Cell.Width = 10
      Grid.Cols(4).Header.Width = 10

      Grid.Cols(5).Cell.Width = 8
      Grid.Cols(5).Header.Width = 8

      Grid.Cols(6).Cell.Width = 10
      Grid.Cols(6).Header.Width = 10

      Grid.Cols(7).Cell.Width = 8
      Grid.Cols(7).Header.Width = 8
      
      Grid.Cols(8).Cell.Width = 10
      Grid.Cols(8).Header.Width = 10
      
      Grid.Cols(9).Cell.Width = 50
      Grid.Cols(9).Header.Width = 50      
      
      
      Grid.Cols(999).Cell.Width = 35
      Grid.Cols(999).Header.Width = 35
      Grid.Cols(999).Cell.NoWrap = True
      
      ' Set fonts, colors for the control columns
      Grid.Cols(0).Header.BgColor = "#90F0FE"
      Grid.Cols(0).Cell.Align = "CENTER"
      Grid.Cols(0).Cell.BgColor = "#FFFFFF"
      Grid.Cols(0).Cell.AltBgColor = "#E0E0E0"
      Grid.Cols(0).Footer.Align = "CENTER"
      Grid.Cols(999).Header.BgColor = "#90F0FE"
      Grid.Cols(999).Cell.Align = "CENTER"      
      Grid.Cols(999).Cell.BgColor = "#FFFFFF"
      Grid.Cols(999).Cell.AltBgColor = "#E0E0E0"      
      Grid.Cols(999).Footer.Align = "CENTER"

      ' Set fonts, colors and sizes for the data columns
      Grid.ColRange(2, 9).Header.Font.Face = "Arial"
      Grid.ColRange(2, 9).Header.Font.Size = 2
      Grid.ColRange(2, 9).Header.BgColor = "#A6CAF0"
      Grid.ColRange(2, 9).Header.NoWrap = True
      Grid.ColRange(2, 9).Cell.Font.Face = "Arial"
      Grid.ColRange(2, 9).Cell.Font.Size = 2
      Grid.ColRange(2, 9).Cell.BgColor = "#FFFFFF"
      Grid.ColRange(2, 9).Cell.AltBgColor = "#E0E0E0"

      ' Grid.Cols(<index>) is equivalent to Grid(<index>) as Cols is the default property
      
      ' Set the SIZE attribute for <INPUT TYPE=TEXT>      '
      Grid("OpLocationid").InputSize = 6
      Grid("InternalTime").InputSize = 6
      Grid("InternalYield").InputSize = 6
    Grid("CustomerTime").InputSize = 6
    Grid("CustomerYield").InputSize = 6
    Grid("EditedDate").InputSize = 10

      ' Display Category field as a drop-down list
      Grid("OpLocationid").AttachForeignTable "select OpLocationId, OpLocationName from OpLocation Where QuerySelection='"&Cstr(session("sessScheme"))&"' ", 1, 2
      
      ' Format the Date column      
    Grid("EditedDate").FormatDate "%d %b %Y", "%d %b %Y"
      Grid("EditedDate").DefaultValue = Date
      Grid("EditedDate").AttachCalendar
      Grid("EditedDate").Cell.NoWrap = True
      
      ' Enable sorting on all visible fields
      Grid.ColRange(2, 9).CanSort = True

      ' Enable client-side confirmation on record deletion
      Grid.DeleteButtonOnClick = "Are you sure you want to delete this record? (This message is cusomizable)"

      Grid.FormOnSubmit = "return Validate();"

      ' Peform server-side validation of date
      If Request("AspGridSave1.x") <> "" Then ' Adding or saving in progress
            If Not IsDate(Request("FIELD9")) Then
                  Response.Write "<B><FONT SIZE=2 FACE=Arial COLOR=#FF0000>Server-side validation: this is not a date!</FONT></B><P>"
                  Grid.IgnoreCommands ' do not save!
            Else ' verify date range
                  TheDate = CDate(Request("FIELD9"))
                  If TheDate < CDate("1/1/1995") Then
                        Response.Write "<B><FONT SIZE=2 FACE=Arial COLOR=#FF0000>Server-side validation: A date must be after 1/1/1995!</FONT></B><P>"
                        Grid.IgnoreCommands ' do not save!
                  End If
            End If
      End If
      
            Grid.Display

      ' Display a total by requerying the same recordset
      Response.Write "<P>"
      Set Rec = grid.Recordset
      Rec.Requery
      InternalTime = 0
      InternalYield = 0
      CustomerTime=0
      CustomerYield=0
      
      while Not Rec.EOF
            InternalTime = InternalTime + Rec("InternalTime")
            InternalYield = InternalYield + Rec("InternalYield")
            CustomerTime = CustomerTime + Rec("CustomerTime")
            CustomerYield = CustomerYield + Rec("CustomerYield")
            Rec.MoveNext
      wend

      Response.Write "<FONT SIZE=3><B>Internal time: " & InternalTime & "</B></FONT><br>"
    Response.Write "<FONT SIZE=3><B>Internal yield: " & InternalYield & "</B></FONT><br>"
    Response.Write "<FONT SIZE=3><B>Customer time: " & CustomerTime & "</B></FONT><br>"
    Response.Write "<FONT SIZE=3><B>Customer yield: " & CustomerYield & "</B></FONT>"
      
      Set Grid = Nothing

%>
</p>
</BODY>
</HTML>

0
Comment
Question by:superabbe
2 Comments
 
LVL 3

Expert Comment

by:ckaneta
ID: 6868212
sounds to me like a regional settings issue.....

but here's some code to change commas into dots

strVar = Replace(strVar,",",".")

so it'd probably be something like this

strVar = RSobj(FieldName)
strVar = Replace(strVar,",",".")
Response.Write strVar

0
 
LVL 1

Accepted Solution

by:
iwebdev earned 250 total points
ID: 6898616
Column Object Method:

If you enter a number greater than 12.1 like 123456789 does it look like 1.234.567,89 ?

See FloatingPoint Method below.

Sub FormatNumeric(Decimal As Integer, Optional ThouComma = True, Optional NegativeSign = True, Optional FloatingPoint = True, Optional Prefix = "" )

Specifies numeric formatting for a column.
Decimal specifies the number of decimal positions for a number.
ThouComma is optional and True by default. If set to False, suppresses comma separators between 000's.
NegativeSign is optional and True by default. If set to False, suppresses the "-" sign for negative numbers and uses the parenthesized (...) form instead.
*****************
FloatingPoint is optional and True by default. If set to False, uses the European format (floating commas and "dot" separators), e.g. 1.234.567,89.
*****************
Prefix is optional and empty by default. Specifies a string prefix that will be automatically inserted in front of each number in the column.


0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now