Field size in Edit mode

Discussion in 'ASP .Net Datagrid Control' started by bruno, Sep 7, 2006.

  1. bruno

    bruno Guest

    Just a basic question:
    I have a very simple gridview with two columns, one sized 20%, the second
    80% and the commandfields (Select, Edit, New) at 10%. The first column is the
    key.
    In edit mode the width of the input field in the second column is too small
    and I don't find the way to enlarge it.
    How can I do? And how can I change the gridview to obtain a multiline input
    field in edit mode?
    Thanks
    --
    bruno
    bruno, Sep 7, 2006
    #1
    1. Advertising

  2. Hi Bruno,

    Please use following code as an example, I'm using the Products table from
    NorthWind database as an example:

    <form id="form1" runat="server">
    <div>
    <asp:GridView Width="100%" ID="GridView1" runat="server"
    AllowPaging="True" AllowSorting="True"
    AutoGenerateColumns="False" DataKeyNames="ProductID"
    DataSourceID="SqlDataSource1">
    <Columns>
    <asp:BoundField ControlStyle-Width="20%"
    DataField="ProductID" HeaderText="ProductID" InsertVisible="False"
    ReadOnly="True" SortExpression="ProductID" />
    <asp:TemplateField ControlStyle-Width="75%">
    <ItemTemplate>
    <asp:Label ID="lblProductName" runat="server"
    Text='<%# Eval("ProductName") %>'></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox ID="txtProductName" runat="server"
    TextMode="MultiLine" Text='<%# Bind("ProductName") %>'></asp:TextBox>
    </EditItemTemplate>
    </asp:TemplateField>
    <asp:CommandField ControlStyle-Width="5%"
    ShowSelectButton="True" ShowEditButton="true" />
    </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    SelectCommand="SELECT [ProductID], [ProductName] FROM
    [Alphabetical list of products]">
    </asp:SqlDataSource>

    </div>
    </form>

    Please tell me whether or not this helps. Thanks.

    Sincerely,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Sep 8, 2006
    #2
    1. Advertising

  3. bruno

    bruno Guest

    many thanks Walter.
    --
    bruno


    "Walter Wang [MSFT]" wrote:

    > Hi Bruno,
    >
    > Please use following code as an example, I'm using the Products table from
    > NorthWind database as an example:
    >
    > <form id="form1" runat="server">
    > <div>
    > <asp:GridView Width="100%" ID="GridView1" runat="server"
    > AllowPaging="True" AllowSorting="True"
    > AutoGenerateColumns="False" DataKeyNames="ProductID"
    > DataSourceID="SqlDataSource1">
    > <Columns>
    > <asp:BoundField ControlStyle-Width="20%"
    > DataField="ProductID" HeaderText="ProductID" InsertVisible="False"
    > ReadOnly="True" SortExpression="ProductID" />
    > <asp:TemplateField ControlStyle-Width="75%">
    > <ItemTemplate>
    > <asp:Label ID="lblProductName" runat="server"
    > Text='<%# Eval("ProductName") %>'></asp:Label>
    > </ItemTemplate>
    > <EditItemTemplate>
    > <asp:TextBox ID="txtProductName" runat="server"
    > TextMode="MultiLine" Text='<%# Bind("ProductName") %>'></asp:TextBox>
    > </EditItemTemplate>
    > </asp:TemplateField>
    > <asp:CommandField ControlStyle-Width="5%"
    > ShowSelectButton="True" ShowEditButton="true" />
    > </Columns>
    > </asp:GridView>
    > <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    > ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    > SelectCommand="SELECT [ProductID], [ProductName] FROM
    > [Alphabetical list of products]">
    > </asp:SqlDataSource>
    >
    > </div>
    > </form>
    >
    > Please tell me whether or not this helps. Thanks.
    >
    > Sincerely,
    > Walter Wang (, remove 'online.')
    > Microsoft Online Community Support
    >
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > ications.
    >
    > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 1 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions or complex
    > project analysis and dump analysis issues. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/subscriptions/support/default.aspx.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
    bruno, Sep 8, 2006
    #3
    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. John J Lee
    Replies:
    3
    Views:
    460
    bruno at modulix
    Dec 1, 2005
  2. Edward Loper
    Replies:
    0
    Views:
    449
    Edward Loper
    Aug 7, 2007
  3. Frank Kurka
    Replies:
    8
    Views:
    290
  4. Jaime Stuardo

    GridView control enters edit mode when I click Edit link twice

    Jaime Stuardo, Apr 7, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    379
    Jaime Stuardo
    Apr 7, 2006
  5. jobs at webdos
    Replies:
    0
    Views:
    446
    jobs at webdos
    Oct 9, 2006
Loading...

Share This Page