How to leave my Gridview in the middle of the screen?

Asked

Viewed 818 times

1

How to leave my Gridview c# in the middle of the screen ?

already tried to put it in a div and attribute aling = center but it didn’t work out.

Someone has a suggestion ?

<asp:GridView ID="GridView1" runat="server" CellPadding="4"
        ForeColor="#333333" GridLines="None" HorizontalAlign = "Center">
    <AlternatingRowStyle BackColor="White" />
    <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
    <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
    <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
    <SortedAscendingCellStyle BackColor="#FDF5AC" />
    <SortedAscendingHeaderStyle BackColor="#4D0000" />
    <SortedDescendingCellStyle BackColor="#FCF6C0" />
    <SortedDescendingHeaderStyle BackColor="#820000" />
</asp:GridView>
  • 1

    Post your code, please

  • 3

    Measure Gridview and type style="width:500px;margin:0 auto 0 auto;" might help

1 answer

0


all right?

When you are creating a Gridview on an ASP.Net page, one of the things you can try is to put a <div></div> around it in order to centralize the Gridview on the page, by assigning text-align: center for your div , but that won’t work. Because the latest CSS doesn’t work this way =(.

In order to do this, assuming you have a CSS class that you are using with Gridview, just add the following CSS to your class:

margin-left: auto;
margin-right: auto;

I hope I’ve helped.

  • The margin: 0 auto; simplifies this @Danilo. But it’s the same thing. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.