DetailsView length of edit textbox

Last post 10-18-2006 2:21 AM by Fredrik N. 2 replies.

Sort Posts:

  • DetailsView length of edit textbox

    10-17-2006, 8:40 AM
    • Member
      45 point Member
    • ruperty
    • Member since 09-14-2006, 10:24 AM
    • Posts 9

    I have a detailsview which accesses a long datafield (5000), but when I go into edit mode the textbox presented is only about 200px.

     
    How do I set the length of this editable field? 

    Regards,

    Rupert,

    http://www.mobiletravelogue.com
     

  • Re: DetailsView length of edit textbox

    10-18-2006, 12:57 AM
    Answer
    • Star
      9,373 point Star
    • rexlin
    • Member since 07-17-2006, 8:43 AM
    • Posts 1,751

    Hi,Rupert:

    You can use the findcontrol to get the TextBox in editTemplate:

      GridView1.Rows[e.NewEditIndex].RowState = DataControlRowState.Edit; 

    TextBox tb=(TextBox)GridView2.Rows[e.NewEditIndex].Cells[2].FindControl("Label1"))

    // do something



    Best Regards,
    __________________________________________________
    Sincerely,
    Rex Lin
    Microsoft Online Community Support

    This posting is provided "AS IS" with on warranties, and confers no rights.
  • Re: DetailsView length of edit textbox

    10-18-2006, 2:21 AM
    • All-Star
      29,644 point All-Star
    • Fredrik N
    • Member since 06-22-2002, 5:03 AM
    • Sweden
    • Posts 5,334

    You can use templates to create your own layout of the DetailView for each mode, you can specify how the DetailsView should look like:

    Example:

            <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="CustomerID"
                DataSourceID="SqlDataSource1" Height="50px" Width="125px">
                <Fields>
                    <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" SortExpression="CustomerID" />
                    <asp:TemplateField HeaderText="CompanyName" SortExpression="CompanyName">
                        <EditItemTemplate>
                            <asp:TextBox Rows="3" TextMode="MultiLine" ID="TextBox1" runat="server" Text='<%# Bind("CompanyName") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <asp:TextBox Rows="3" TextMode="MultiLine" ID="TextBox1" runat="server" Text='<%# Bind("CompanyName") %>'></asp:TextBox>
                        </InsertItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("CompanyName") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName" />
                </Fields>
            </asp:DetailsView>

    /Fredrik Normén - fredrikn @ twitter

    ASPInsider

    Microsoft MVP, MCSD, MCAD, MCT

    ASPInsiders
    My Blog
Page 1 of 1 (3 items)