Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Maxlength Property
Message
De
24/08/2010 21:29:24
 
 
À
24/08/2010 19:51:54
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
Divers
Thread ID:
01478153
Message ID:
01478280
Vues:
22
>The textbox.text data originates in a vfp table. Debugging showed that although there were only 3 characters, the textbox thinks that the text contains 10 (the length of the VFP field), making it equal to the maxlength of textbox.
>
>I trimmed the textbox.text and the problem went away.


Actually, the textbox doesn't think that the text contained 10 characters, it actually did contain 10 characters, 3 characters padded with 7 spaces. That's why the .Trim() took care of it.

This can also happen with SQL Server CHAR columns. A column defined as CHAR(10) will be padded with spaces to a total of 10 characters, whereas a column defined as VARCHAR(10) will not have the extra spaces. (I believe that that's with the default settings, which I *think* can be changed by SET ANSI PADDING ... I'm no SQL Server expert though ... I know enough to be dangerous. <g>)

~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform