resize bound textbox to datagrid

Posted on 2005-04-08
Last Modified: 2008-02-01

I'm having a problem resizing the controls width (textbox). When user clicks the datagrid, a textbox will appear for editing purposes, i'm not sure where the textbox is located, i think it's bound to the datagrid?

Please kindly guide me to resize the textbox when it appears.

ItemStyle-Width="40px" <-----------this one resizes the datagrid column only, we need the textbox..

>><asp:BoundColumn DataField="break1" HeaderText="First Break"></asp:BoundColumn><<


                    <asp:DataGrid id="DataGrid1" runat="server" Font-Names="Verdana" Font-Size="XX-Small" DataKeyField="operatorshiftid" AutoGenerateColumns="False" CellPadding="4" onPageIndexChanged="pageGrid" AllowPaging="True" PageSize="50" OnDeleteCommand="manage_delete" OnUpdateCommand="manage_update" OnCancelCommand="manage_cancel_edit" OnEditCommand="manage_edit" OnItemDataBound="manage_ItemDataBound">
                <HeaderStyle font-bold="True"></HeaderStyle>
                    <asp:BoundColumn DataField="operatorid" ReadOnly="True" HeaderText="Operator ID"></asp:BoundColumn>
                    <asp:BoundColumn DataField="operatorname" ReadOnly="True" HeaderText="Operator Name"></asp:BoundColumn>
                    <asp:BoundColumn DataField="shiftdate" ReadOnly="True" HeaderText="Shift Date"></asp:BoundColumn>
                    <asp:TemplateColumn HeaderText="Start Time">
                            <%# Container.DataItem("starttime")%>
                            <asp:Label id="lblSelected1" visible="false" text=<%# DataBinder.Eval(Container.DataItem, "starttime") %> runat="server"/>
                            <asp:DropDownList ID="DropDownList1" runat="server" />
                    <asp:BoundColumn DataField="break1" HeaderText="First Break"></asp:BoundColumn>
                    <asp:BoundColumn DataField="lunch" HeaderText="Lunch Break"></asp:BoundColumn>
                    <asp:BoundColumn DataField="break2" HeaderText="Second Break"></asp:BoundColumn>
                    <asp:BoundColumn DataField="endtime" ReadOnly="True" HeaderText="End Time"></asp:BoundColumn>
                    <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
                    <asp:ButtonColumn Text="Delete" CommandName="Delete"></asp:ButtonColumn>
                <PagerStyle horizontalalign="Right" position="TopAndBottom" pagebuttoncount="20" mode="NumericPages"></PagerStyle>
Question by:lynnton
    LVL 9

    Accepted Solution

    Step 1)  Convert all your edit columns to Template Columns.  You can do this by right click on the datagrid > property builder > columns > click on the column > "Convert to Template Column"

    Step 2) Right click datagrid > Edit Template > Select your column > when the textbox appears drag it to desired width or specify new width in properties window
    LVL 1

    Author Comment


    Step 1 is done.

    I'm not able to accomplish step 2, don't see any edit template

    LVL 4

    Assisted Solution

    Hi lynnton,

    If you go to the HTML view and have a look for the <Columns> section of your datagrid.  Look for the <asp:TemplateColumn> tag then under that you should see <ItemTemplate>.  Look for a <EditItemTemplate> tag at the same level as the <ItemTemplate> tag.  If there isn't one, add one.  Here you can add the controls for your edit command!

    Hope this is of some help,


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    758 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

    11 Experts available now in Live!

    Get 1:1 Help Now