Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Gridview and column name problem

Posted on 2009-02-21
3
Medium Priority
?
482 Views
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" />
        <Columns>
            <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" />
        </Columns>
        <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" />
    </asp:GridView>

Open in new window

screenshot009.jpg
0
Comment
Question by:JeffEae
3 Comments
 
LVL 14

Accepted Solution

by:
_Stilgar_ earned 1000 total points
ID: 23702164
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.
0
 
LVL 8

Assisted Solution

by:tiagosalgado
tiagosalgado earned 1000 total points
ID: 23702834
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
</div>

Open in new window

0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 23703243
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"/>
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

581 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