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

ASP.NET

Avatar of undefined
Last Comment
Murray Brown
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>
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

similar for your text input, what if applied width=100% ?
Avatar of Murray Brown
Murray Brown
Flag of United Kingdom of Great Britain and Northern Ireland image

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Murray Brown
Murray Brown
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Thanks very much. Sorry about late acceptance
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo