2017-06-05 38 views
0

我有一個GridView。 我試圖把標題居中沒有什麼作品將Gridview列的標題對齊到中心

<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> 
+0

這似乎並非是一個問題,中心... ... – Rook

回答

0

發現這個解決方案是在做題的一個

你可以做這樣的事情

嘗試添加CssClass到您的GridView從您的ASPX代碼中,爲您的課程分配以下樣式。

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

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

這將設置你的所有列文本你的GridView