joshdick joshdick - 4 months ago 44
ASP.NET (C#) Question

How do I set the width of a textbox when editing a row in a GridView?

I've got a GridView that can be edited. My problem is that when I click Edit, the textbox is too small (the

File Name
column). It isn't large enough to display its contents, and it isn't as wide as the rest of the column.

How can I make that textbox wider?

Here's the ASP code:

<asp:GridView ID="FileGridView" runat="server" AllowPaging="True" OnPageIndexChanging="FileGridView_PageIndexChanging"
CellPadding="1" CssClass="GridView" GridLines="Horizontal"
Width="100%" AutoGenerateColumns="false"
OnRowCancelingEdit="GridView_RowCancelingEdit" OnRowEditing="GridView_RowEditing" OnRowUpdating="GridView_RowUpdating"
<asp:BoundField DataField="Name" HeaderText="File Name" />
<asp:BoundField DataField="Length" HeaderText="Size" ReadOnly="true" />
<asp:BoundField DataField="LastWriteTime" HeaderText="Last Modified" ReadOnly="true" />
<RowStyle CssClass="GridViewRow" />
<EditRowStyle ForeColor="Black" CssClass="GridViewEditRow" />
<SelectedRowStyle Font-Bold="True" CssClass="GridViewSelectedRow" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle CssClass="GridViewHeader" ForeColor="White" />
<AlternatingRowStyle CssClass="GridViewAlternatingRow" />

There's C# code behind this to update the data, and that works just fine. I hope the solution to this is in the ASP, but if the solution requires some C# code, that's OK with me.


This should work:

<asp:BoundField DataField="Name" HeaderText="File Name" />
    <controlstyle Width="200">