2 Replies Latest reply on Jun 6, 2006 10:42 AM by ixnay5

    How to limit number of chars in a CFGRIDCOLUMN

    ixnay5
      Hi,

      I have a 2 column grid populated from a query. The grid is editable and will be submitted to an action page for database Delete, Insert, or Update. The first grid column corresponds to a MS SQL database column that is defined as varchar(3).

      Currently, if the user inputs 4 characters and submits, I get a SQL trunc error.

      There has to be a way to limit the number of characters in this cfgridcolumn to 3? How is it done?
        • 1. Re: How to limit number of chars in a CFGRIDCOLUMN
          paross1 Level 2
          Well, you could check the number of characters on your action page, and bounce them back if it exceeds the maximum number, and you can "protect" the database by including a limiting function on the data in the insert statement, like LEFT(col, 3) so that regardless what they specify, you will only insert the first 3 into the database. You really should let them know if they entered too many, however.

          Phil
          • 2. Re: How to limit number of chars in a CFGRIDCOLUMN
            ixnay5 Level 1
            Thanks.

            I thought of doing it on the server like that. If I'm going to bounce them back I'd want to find a way to preserve the changes they made.

            I was hoping there was a way to simply prevent the entry of a 4th char in the first place.