Solved

ASP.NET DetailsView Update exception handling - truncated data

Posted on 2015-01-03
2
101 Views
Last Modified: 2015-01-04
I'm using a DetailsView for updating a record. If the edit input of some fields is too long, the system produces a "data will be truncated" exception.

I can see where I can detect the error in DetailsViewItemUpdating or DetailsViewItemUpdated, and provide a user message.  However, I believe the visual feedback should be sufficient for this release, i.e. "hey, it didn't take my 30 characters, even though the header label said it would only allow 20".

Is there a way to force the DetailsView to do the truncation and accept the update?

Or some other approach to this data handling exception, which must be pretty common.
0
Comment
Question by:codequest
2 Comments
 
LVL 12

Accepted Solution

by:
Ammar Gaffar earned 500 total points
ID: 40529945
I think it is better to convert targeted column to TemplateField, and place text box inside Column's EditItemTemplate set the DataBindings property and from here you will have text box that can set MaxLength property to 20.
This way your text box will not accept more than 20 chars so you will be fine.

Good Luck
0
 
LVL 2

Author Comment

by:codequest
ID: 40530335
Worked well.  Very slick.  Thanks, big help!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

911 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

22 Experts available now in Live!

Get 1:1 Help Now