Gridview and column name problem

Posted on 2009-02-21
Last Modified: 2013-11-07
Hi, I've got a gridview that displays about 6 columns, but when I view it, the rows seem to be out of step with the column names themselves.  I'll send a screenshot to show you what I mean.  It doesn't matter if I resize the window or anything, the column name seems to be a little ahead of the row

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 

        CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="Blue" GridLines="None" 

        style="margin-right: 0px" Width="1000px">

        <RowStyle BackColor="#EFF3FB" />


            <asp:BoundField DataField="fileid" HeaderText="ID" 

                SortExpression="fileid" />

            <asp:BoundField DataField="title" HeaderText="Title" SortExpression="title" />

            <asp:BoundField DataField="subtitle" HeaderText="Subtitle" 

                SortExpression="subtitle" />

            <asp:BoundField DataField="date" HeaderText="Date" 

                SortExpression="date" />

            <asp:BoundField DataField="filesize" HeaderText="File Size" 

                SortExpression="filesize" />


        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />

        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />

        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />

        <HeaderStyle BackColor="#507CD1" BorderColor="#0033CC" Font-Bold="True" 

            ForeColor="White" />

        <EditRowStyle BackColor="#2461BF" />

        <AlternatingRowStyle BackColor="White" />


Open in new window

Question by:JeffEae
    LVL 14

    Accepted Solution

    That is because the table header has its cells centered, while the fields in the rows are left-aligned. Either change the styles for the header cells, or for the rows.

    Something like: <HeaderStyle TextAlign="Left" ....

    Should do the job.
    LVL 8

    Assisted Solution

    If you want to center all gridview you can put it inside a <div> and apply it a style like this

    <div style="text-align:center">
    your gridview here

    Open in new window

    LVL 26

    Expert Comment

    by:Anurag Thakur
    after modifying the line in the grid the titles row and the data row are left aligned
    <HeaderStyle BackColor="#507CD1" BorderColor="#0033CC" Font-Bold="True" ForeColor="White" HorizontalAlign="Left"/>

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    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.…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    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…

    731 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

    18 Experts available now in Live!

    Get 1:1 Help Now