[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2094
  • Last Modified:

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

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
cgipisani
Asked:
cgipisani
  • 2
  • 2
1 Solution
 
Bob LearnedCommented:
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
 
cgipisaniAuthor Commented:
How would the Template Field work?  Do you give the TextBox the DataField attribute that would be part of the BoundField?
0
 
Bob LearnedCommented:
Short snippet:

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

Bob
0
 
cgipisaniAuthor Commented:
This worked after putting that code inside of <asp:TemplateField>

Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now