locked
getting rid of trailing spaces RRS feed

  • Question

  • User834654336 posted

    I came across a problem in editing data stored database.

    in my grid item template text field, it pulls a nchar(10) data value out of database, but the data may not be 10 characters long, 

    so the database always add the trailing spaces for the rest of the characters.

    Even when I press EDIT and delete the trailing spaces, when I press UPDATE the trailing spaces will be added back in.


    now I have validation controls that specific says no spaces allowed, so every time I EDIT something and UPDATE, I have to delete that trailing space even though I didn't change anything for that text field.

     

    Is there a way say when I press EDIT in the Gridview, I treat it as an event, and delete trailing spaces in the that text field in some C# code, so when I press update the trailing spaces won't be there?

    How do I find this event? and how do I delete the trailing spaces in C# code?

     

    So Basically my goal is to delete the trailing spaces by the time user get to edit the text in the text field, so even when user did not edit anything and press update instead, it will not be stopped by the validation tool for trailing spaces.

     

     

    Tuesday, April 28, 2009 1:01 PM

Answers

  • User-442214108 posted

    if the data is of a variable length - change nchar(10) to varchar(10) - -

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 28, 2009 1:04 PM