-1

I have a GridView . I am trying to bring the headers to center nothing works

 <asp:GridView ID="GridviewDataCoupon" runat="server" Style="text-align: center" Visible="false" ShowFooter="true" Width="99%"
                                AutoGenerateColumns="false">
                                <Columns>

                                <asp:TemplateField HeaderText="End Date" HeaderStyle-BackColor="#99CCCC">
                                        <ItemTemplate>
                                            <asp:Label ID="lbl4" runat="server" Text='<%# Eval("end_date") %>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>

                                <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                                <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
                                <AlternatingRowStyle BackColor="WhiteSmoke" ForeColor="Black" />
                                <RowStyle BackColor="White" ForeColor="Black" />
                                <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                                <SortedAscendingCellStyle BackColor="#EDF6F6" />
                                <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
                                <SortedDescendingCellStyle BackColor="#D6DFDF" />
                                <SortedDescendingHeaderStyle BackColor="#002876" />
                            </asp:GridView>
Frost_Mourne
  • 342
  • 4
  • 22

1 Answers1

0

Found this solution to it in one of the SO Questions

You can do something like this

Try adding a CssClass to your GridView from your ASPX code, and assign following styles to your class.

 <style type="text/css">
        .GridHeader td, .GridHeader th
        {
            text-align: center;
        }
    </style>

 <asp:GridView CssClass="GridHeader" runat="server">

This will set all your columns text to center in your gridview

Frost_Mourne
  • 342
  • 4
  • 22