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

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
what if changing to something like this?

<asp:Label ID="lblTotalWeight" runat="server" Text='<%# Bind("[Total Weight]")%>' Width="100%" ></asp:Label>
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
similar for your text input, what if applied width=100% ?
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
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

1
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
isn't that Textbox control in ASP.NET will generate the HTML Input element as well?

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

have you try to amend the class as well as the style part? It could affecting how your element being presented.

have you compare what's the HTML output generated that using TextBox control against the "input" element?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much. Sorry about late acceptance
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.