I need to set the width of gridview columns in edit mode. Visual Studio 2005

Posted on 2007-10-15
Last Modified: 2013-11-26
I need to set the width of gridview columns in edit mode.

I have a gridview that works well. However the column in edit mode are much wider that necessary.
I am not using templates?

Do I need to use edit templates? If so, then please supply a hint or reference for setting the edit column widths and data format for decimal and string values.

Question by:Dovberman
    LVL 96

    Accepted Solution

    You need to set the width for the column in the edit template.


    Author Comment

    Yes, but how?

    This is my code for the template columns.
    They are still as wide as before.

    <asp:GridView ID="grdPurchases" runat="server" AutoGenerateColumns="False" DataKeyNames="BuyTransID"
                DataSourceID="dscPurchases" AllowPaging="True" AllowSorting="True">
                    <asp:CommandField ShowEditButton="True" ShowSelectButton="True" />
                    <asp:TemplateField HeaderText="Broker Acct" SortExpression="BrokerAccount">
                            <asp:TextBox ID="txtBrokerAccount" runat="server" Text='<%# Bind("BrokerAccount") %>'>
                        <ItemStyle HorizontalAlign="Left" Width="20px" Wrap="False" />
                    <asp:TemplateField HeaderText="BuyQty" SortExpression="BuyQty">
                            <asp:TextBox ID="txtBuyQty" runat="server" Text='<%# Bind("BuyQty") %>'></asp:TextBox>
                        <ItemStyle Width="10px" />
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("BuyQty") %>'></asp:Label>

    Author Comment

    Please close this question.
    I have not received a workable answer.
    Meanwhile, I figured it out myself.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now