gpt4 book ai didi

css - 右对齐 GridView 中包含数字的所有列(值)

转载 作者:行者123 更新时间:2023-11-28 09:34:51 26 4
gpt4 key购买 nike

我想右对齐包含数值的所有列(仅值),但我没有找到确切的解决方案。

我正在使用非常简单的 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;
}

aspx文件中的GridView

<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,但它不起作用。

如何将列与数字右对齐?

谢谢!

最佳答案

    <asp:BoundField DataField="Debit" HeaderText="Debit" ReadOnly="True" SortExpression="Debit" DataFormatString="{0:N2}" HtmlEncode="False" ItemStyle-HorizontalAlign ="Right"  >
</asp:BoundField>

关于css - 右对齐 GridView 中包含数字的所有列(值),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25579823/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com