DetailsView edit and insert row widths

Discussion in 'ASP .Net' started by William LaMartin, Jan 22, 2006.

  1. Is there a way to increase the width of the text boxes for the DetailsView
    in edit or insert mode? When I put the control in either edit or insert
    mode, the text boxes to type the new text are always much smaller than the
    available space in the row.
    William LaMartin, Jan 22, 2006
    #1
    1. Advertising

  2. > Is there a way to increase the width of the text boxes for the DetailsView
    > in edit or insert mode? When I put the control in either edit or insert
    > mode, the text boxes to type the new text are always much smaller than the
    > available space in the row.


    I do not know an obvious answer to that. However, there are two
    possibilities:

    a) use TemplateFields instead of BoundFields. this way you precisely define
    how the edit/insert template looks like so you easily add required
    attributes to TextBoxes that you place in templates (I prefer this techique)
    b) write a DataBound event handler with a foreach loop for DetailsView's
    rows. inside a loop you check if the row contains a TextBox and set
    TextBox's width to 100% (I didn't exactly tested that in your scenario but I
    use this technique constantly to tweak DetailsView's apperance in other
    cases, for example to remove/disable buttons of a CommandField).

    If another possibility exists I would be glad to learn it.

    Regards,
    Wiktor Zychla
    Wiktor Zychla [C# MVP], Jan 22, 2006
    #2
    1. Advertising

  3. Changing to template fields worked fine since there is a width attribute.

    Thanks

    "Wiktor Zychla [C# MVP]" <wzychla_ii.uni.wroc.pl> wrote in message
    news:%...
    >> Is there a way to increase the width of the text boxes for the
    >> DetailsView in edit or insert mode? When I put the control in either edit
    >> or insert mode, the text boxes to type the new text are always much
    >> smaller than the available space in the row.

    >
    > I do not know an obvious answer to that. However, there are two
    > possibilities:
    >
    > a) use TemplateFields instead of BoundFields. this way you precisely
    > define how the edit/insert template looks like so you easily add required
    > attributes to TextBoxes that you place in templates (I prefer this
    > techique)
    > b) write a DataBound event handler with a foreach loop for DetailsView's
    > rows. inside a loop you check if the row contains a TextBox and set
    > TextBox's width to 100% (I didn't exactly tested that in your scenario but
    > I use this technique constantly to tweak DetailsView's apperance in other
    > cases, for example to remove/disable buttons of a CommandField).
    >
    > If another possibility exists I would be glad to learn it.
    >
    > Regards,
    > Wiktor Zychla
    William LaMartin, Jan 23, 2006
    #3
  4. William LaMartin

    mkamba

    Joined:
    Nov 25, 2008
    Messages:
    1
    For what it's worth two years later...

    You don't need to change this to a TemplateField. You can use the ControlStyle and the ItemStyle to set the Width.

    <asp:BoundField DataField="MyField" HeaderText="My Field" SortExpression="MyField" >
    <ControlStyle Width="200px" />
    <ItemStyle Width="200px" />
    </asp:BoundField>

    As you can probably guess, the ItemStyle will change the width in view mode and the ControlStyle will change the width of the textbox in Edit mode.

    I hope this saves some future searcher the small headache of converting all their fields to do this.
    mkamba, Nov 25, 2008
    #4
  5. William LaMartin

    mrpink

    Joined:
    Mar 29, 2009
    Messages:
    1
    ItemStyle & ControlStyle

    Thanks, Mkamba. That worked.
    mrpink, Mar 29, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cannontrodder
    Replies:
    1
    Views:
    712
    cannontrodder
    Jul 25, 2006
  2. cheshire2k
    Replies:
    0
    Views:
    621
    cheshire2k
    Nov 9, 2006
  3. David Ching
    Replies:
    2
    Views:
    1,480
    David Ching
    Aug 31, 2007
  4. The_ShotSpotter_Team

    How to access controls in Edit and Insert templates of DetailsView

    The_ShotSpotter_Team, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    189
    Brock Allen
    Aug 30, 2005
  5. Feege
    Replies:
    0
    Views:
    437
    Feege
    Dec 20, 2005
Loading...

Share This Page