Shifting gridview headers to the left

Posted on 2011-10-04
Last Modified: 2012-06-27
I have a gridview (sceenshot attached). You see how the header is shifted to the right. I used controlstyle css to move it to the left but doesnt look like that's the correct one...

How can I do this? Part of the grid code is also below
<asp:TemplateField    HeaderText="User Name">
           <ItemTemplate  >
              <asp:Label ID="Labelx" runat="server" Text='<%# Eval("Username") %>' >
           <EditItemTemplate >
               <asp:TextBox ID="txtUserName" runat="server" Text='<%# Eval("Username")%>'  ></asp:TextBox>
               <span class="feedback"><asp:RequiredFieldValidator ControlToValidate="txtUserName" runat="server" ID="rfv1" Text="User Name is required!" ErrorMessage="User Name is required!"></asp:RequiredFieldValidator></span>
           <asp:TemplateField  HeaderText="Business Name">
               <asp:Label ID="Label1" runat="server" Text='<%# Eval("BusinessName") %>'></asp:Label>

Open in new window

Question by:Camillia
    LVL 38

    Expert Comment

    by:Tom Beck
    <asp:TemplateField HeaderText="User Name" HeaderStyle-HorizontalAlign="Left">
    LVL 38

    Accepted Solution

    Or just add this just below your <asp:Gridview> control tag to get all header text aligned left:

    <HeaderStyle HorizontalAlign="Left" />

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    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

    14 Experts available now in Live!

    Get 1:1 Help Now