Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

ASP.net How do I get the width of an input box and a GridView column to match

Hi. In my ASP.net web app I am trying to get the width of an input box and a GridView template column. The two do not look the same size.

What might I be doing wrong. The markup code for them is shown below

<input id="TotalWeight2" runat="server" type="text" placeholder="To"   class="auto-style8" style="font-size: medium; width:75px"/>

Open in new window


                    <asp:TemplateField HeaderText="Total Weight" SortExpression="Total Weight" ItemStyle-HorizontalAlign="Left" ItemStyle-Wrap="true" >
                            <ItemTemplate>
                            <asp:Label ID="lblTotalWeight" runat="server" Text='<%# Bind("[Total Weight]")%>' Width="75" ></asp:Label>
                            </ItemTemplate> 
                    </asp:TemplateField>

Open in new window

Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

what if changing to something like this?

<asp:Label ID="lblTotalWeight" runat="server" Text='<%# Bind("[Total Weight]")%>' Width="100%" ></asp:Label>
similar for your text input, what if applied width=100% ?
Avatar of Murray Brown

ASKER

Hi Ryan. Won't that stretch it across the whole screen. Here is an image showing the white input boxes compared
to my GridView template columns. When I used textboxes instead of <input> boxes things aligned well by making each
box the same width as the column

User generated image
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks very much. Sorry about late acceptance