2017-06-05 11 views
0

私にはGridViewがあります。 私は何をセンタリングしないようにヘッダを持参しようとしていますグリッドビュー列のタイトルを中央に合わせるには

あなたのに CssClassを追加するこの

てみような何かを行うことができSO質問

の一つで、それには、この解決策を見つけた

<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

の作品ASPXコードのGridViewを入力し、次のスタイルをクラスに割り当てます。

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

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

これはあなたのGridViewこれが問題ではないよう

関連する問題