Solved

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

Posted on 2006-10-31
4
1,961 Views
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?
0
Comment
Question by:cgipisani
  • 2
  • 2
4 Comments
 
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.

Bob
0
 

Author Comment

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

Accepted Solution

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

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

Bob
0
 

Author Comment

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

Thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

680 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