Solved

Validation of data string length in a dataGrid

Posted on 2003-11-12
1
409 Views
Last Modified: 2010-04-16
How do we prevent overlong strings being entered into a cell column within a dataGrid (and / or FlexGrid component).
We're allowing the users to work with entries in a grid and want to prevent them entering strings that would be truncated when attempting to post to the underlying database.
We can't see a simple way of doing this.
Can anyone shed some light on this for us ?
The only way we can see at present is to validate after leaving the cell - but I'm hoping that there's a cuter way.

Thanks in advance
Steve
0
Comment
Question by:StevenK
1 Comment
 
LVL 20

Accepted Solution

by:
TheAvenger earned 25 total points
ID: 9731090
There surely is: you should take the edit control through which the data is entered and set it's max length value. For this you need to have a data grid with DataGridTableStyle and DataGridTextBoxColumn for this column. Then you have:
dataGridTextBoxColumn.TextBox.MaxLength = 30;
And here you go!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 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

19 Experts available now in Live!

Get 1:1 Help Now