Is there a way to set MaxLength on a BoundField within a DetailsView control?

Posted on 2006-10-31
Last Modified: 2010-05-19
Within a DetailsView control I have several BoundField controls.  When I am in edit or insert mode for the DetailsView control, a TextBox is created for each BoundField.  How can I set the MaxLength property for these TextBox's?
Question by:cgipisani
  • 2
  • 2
LVL 96

Expert Comment

by:Bob Learned
ID: 17849007
Instead of a BoundField, you could define a Template field, and hard code the TextBox with MaxLength set.  It might also be possible to get a reference to the TextBox from the BoundField, but that would be significantly more difficult.


Author Comment

ID: 17849067
How would the Template Field work?  Do you give the TextBox the DataField attribute that would be part of the BoundField?
LVL 96

Accepted Solution

Bob Learned earned 250 total points
ID: 17849089
Short snippet:

    <asp:TextBox runat="server" ID="TextBox1" Text='<%# Bind("Field1") %>' />


Author Comment

ID: 17849145
This worked after putting that code inside of <asp:TemplateField>


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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Sending a Secure fax is easy with eFax Corporate ( First, just open a new email message. In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

13 Experts available now in Live!

Get 1:1 Help Now