0
我想右对齐包含数值的所有列(仅限值),但我找不到确切的解决方案。右对齐在GridView中包含数字的所有列(值)
我使用非常简单的aspx页面和波纹管皮肤文件:
<asp:GridView SkinID="MyGrid" runat="server" CssClass="GridHeader" Width="800px" CellPadding="4">
<FooterStyle BackColor="#336699" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#336699" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
<PagerSettings PageButtonCount="40" />
</asp:GridView>
CSS文件居中标题(字幕)
.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;
}
GridView控件在aspx文件
<asp:GridView ID="gvCashbookAFA" runat="server" SkinID="MyGrid" Width="100%" AutoGenerateColumns="False"
DataSourceID="objgvCashbookAFA" AllowSorting="True" AllowPaging="True"
PageSize="50" onpageindexchanging="gvCashbookAFA_PageIndexChanging">
<Columns>
<asp:BoundField DataField="No" HeaderText="No" SortExpression="No" ReadOnly="True" />
<asp:BoundField DataField="ReferenceNumber" HeaderText="Ref #" SortExpression="ReferenceNumber" />
<asp:BoundField DataField="TransactionType" HeaderText="Transaction Type" SortExpression="TransactionType" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="Donor" HeaderText="Donor" SortExpression="Donor"></asp:BoundField>
<asp:BoundField DataField="OrderDate" HeaderText="Order Date" SortExpression="OrderDate"
DataFormatString="{0:dd-MMM-yyyy}" HtmlEncode="False" />
<asp:BoundField DataField="Debit" HeaderText="Debit" ReadOnly="True" SortExpression="Debit"
DataFormatString="{0:N2}" HtmlEncode="False" >
<ItemStyle HorizontalAlign="Right" />
</asp:BoundField>
<asp:BoundField DataField="Credit" HeaderText="Credit" SortExpression="Credit"
DataFormatString="{0:N2}" >
<ItemStyle HorizontalAlign="Right" />
</asp:BoundField>
<asp:BoundField DataField="Balance" HeaderText="Balance" ReadOnly="True" SortExpression="Balance"
DataFormatString="{0:N2}" HtmlEncode="False" >
<ItemStyle HorizontalAlign="Right" />
</asp:BoundField>
</Columns>
</asp:GridView>
数字列非常清晰,我还将ItemStyle
应用于这些列,b它不工作。
如何正确对齐列与数字?
谢谢!
谢谢,我必须明确写出每一列,我想要的是我想有一个Css,只能右对齐与列数字。 – ARH 2014-08-30 07:47:50