title: Right align all columns (values) which contains numbers in GridView
body: <p>I would like to right align all columns (values only) containing number values, but I am not finding the exact solution. </p>
  
  <p>I am using very simple aspx page and skin file as bellow:</p>
  
  <pre><code>&lt;asp:GridView SkinID="MyGrid" runat="server"  CssClass="GridHeader" Width="800px" CellPadding="4"&gt;
          &lt;FooterStyle BackColor="#336699" Font-Bold="True" ForeColor="White"  /&gt;
          &lt;PagerStyle BackColor="#336699" ForeColor="White" HorizontalAlign="Center" /&gt;
          &lt;SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /&gt;
          &lt;EditRowStyle BackColor="#2461BF" /&gt;
          &lt;AlternatingRowStyle BackColor="White" /&gt;
          &lt;PagerSettings PageButtonCount="40" /&gt;
  &lt;/asp:GridView&gt;   
  </code></pre>
  
  <p>The Css file to center the headers (caption)</p>
  
  <pre><code>.GridHeader caption
  {
      color:White;
      background-color:#6299c5;
      font-weight:bold;
      text-align:left;
      border-bottom: 1px solid white;
      padding:5px;
  }
  .GridHeader th, .GridHeader th a 
  {
      text-align:center;
      background-color:#336699;
      color:White;
      font-weight:200;
  }
  </code></pre>
  
  <p>The GridView in aspx file</p>
  
  <pre><code>&lt;asp:GridView ID="gvCashbookAFA" runat="server" SkinID="MyGrid" Width="100%" AutoGenerateColumns="False"
                          DataSourceID="objgvCashbookAFA" AllowSorting="True" AllowPaging="True" 
                          PageSize="50" onpageindexchanging="gvCashbookAFA_PageIndexChanging"&gt;
                          &lt;Columns&gt;
                              &lt;asp:BoundField DataField="No" HeaderText="No" SortExpression="No" ReadOnly="True" /&gt;
                              &lt;asp:BoundField DataField="ReferenceNumber" HeaderText="Ref #" SortExpression="ReferenceNumber" /&gt;
                              &lt;asp:BoundField DataField="TransactionType" HeaderText="Transaction Type" SortExpression="TransactionType" /&gt;
                              &lt;asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" /&gt;
                              &lt;asp:BoundField DataField="Donor" HeaderText="Donor" SortExpression="Donor"&gt;&lt;/asp:BoundField&gt;
                              &lt;asp:BoundField DataField="OrderDate" HeaderText="Order Date" SortExpression="OrderDate"
                                  DataFormatString="{0:dd-MMM-yyyy}" HtmlEncode="False" /&gt;
                              &lt;asp:BoundField DataField="Debit" HeaderText="Debit" ReadOnly="True" SortExpression="Debit"
                                  DataFormatString="{0:N2}" HtmlEncode="False" &gt;
                              &lt;ItemStyle HorizontalAlign="Right" /&gt;
                              &lt;/asp:BoundField&gt;
                              &lt;asp:BoundField DataField="Credit" HeaderText="Credit" SortExpression="Credit" 
                                  DataFormatString="{0:N2}" &gt;
                              &lt;ItemStyle HorizontalAlign="Right" /&gt;
                              &lt;/asp:BoundField&gt;
                              &lt;asp:BoundField DataField="Balance" HeaderText="Balance" ReadOnly="True" SortExpression="Balance"
                                  DataFormatString="{0:N2}" HtmlEncode="False" &gt;
                              &lt;ItemStyle HorizontalAlign="Right" /&gt;
                              &lt;/asp:BoundField&gt;
                          &lt;/Columns&gt;
                      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>The number columns are very clear and I also applied <code>ItemStyle</code> to those columns, but its not working.</p>
  
  <p>How can I right align the columns with numbers?</p>
  
  <p>Thanks!</p>