Solved

ASP.NET DetailsView Update exception handling - truncated data

Posted on 2015-01-03
2
100 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
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.…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

10 Experts available now in Live!

Get 1:1 Help Now