gpt4 book ai didi

c# - 如何将 Gridview 标题对齐到右边?

转载 作者:太空宇宙 更新时间:2023-11-03 10:33:26 25 4
gpt4 key购买 nike

我正在尝试将 gridview 的标题对齐到 RIGHT 但它不起作用,我什至尝试了居中等但它们都不起作用但它适用于元素。我想将 CR、DR 列的 HEADER 右对齐,请帮忙,我看了很多文章但没有帮助。

<asp:GridView ID="GridViewLedger" runat="server" Width="100%" AutoGenerateColumns="False"
ShowFooter="True" DataKeyNames="AccountID"
CssClass="table table-hover table-striped table-bordered">
<Columns>
<%-- <asp:BoundField HeaderText="TransactionID" DataField="TransactionID" ItemStyle-CssClass="visible-desktop"
HeaderStyle-CssClass="visible-desktop" />
<asp:BoundField HeaderText="Account ID" DataField="Account_ID" ItemStyle-CssClass="visible-desktop"
HeaderStyle-CssClass="visible-desktop" />--%>
<asp:BoundField HeaderText="Account Title" DataField="AccountTitle" ItemStyle-CssClass="visible-desktop"
HeaderStyle-CssClass="visible-desktop">
<HeaderStyle CssClass="visible-desktop"></HeaderStyle>

<ItemStyle Width="11%" />
</asp:BoundField>
<asp:BoundField HeaderText="Voucher No" DataField="VoucherNumber" ItemStyle-CssClass="visible-desktop"
HeaderStyle-CssClass="visible-desktop">
<HeaderStyle CssClass="visible-desktop"></HeaderStyle>

<ItemStyle Width="8%"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Chq No" DataField="ChequeNumber" ItemStyle-CssClass="visible-desktop"
HeaderStyle-CssClass="visible-desktop">
<HeaderStyle CssClass="visible-desktop"></HeaderStyle>

<ItemStyle Width="8%" CssClass="visible-desktop"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="DateTime" DataFormatString="{0:dd/MMM/yyyy hh:mm}" HtmlEncode="false" DataField="TransactionDateTime" ItemStyle-CssClass="visible-desktop"
HeaderStyle-CssClass="visible-desktop">
<HeaderStyle CssClass="visible-desktop"></HeaderStyle>

<ItemStyle Width="13%" CssClass="visible-desktop"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="InvoiceNo" DataField="InvoiceNo" ItemStyle-CssClass="visible-desktop"
HeaderStyle-CssClass="visible-desktop">
<HeaderStyle CssClass="visible-desktop"></HeaderStyle>

<ItemStyle Width="3%" CssClass="visible-desktop" ></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Particulars" DataField="Particulars" ItemStyle-CssClass="visible-desktop"
HeaderStyle-CssClass="visible-desktop">
<HeaderStyle CssClass="visible-desktop"></HeaderStyle>

<ItemStyle CssClass="visible-desktop" Width="30%"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="DR" DataField="DR" ItemStyle-CssClass="visible-desktop"
HeaderStyle-CssClass="visible-desktop">
<HeaderStyle CssClass="visible-desktop" HorizontalAlign="Right"></HeaderStyle>

<ItemStyle CssClass="visible-desktop" Width="8%" HorizontalAlign="Right"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="CR" DataField="CR" ItemStyle-CssClass="visible-desktop"
HeaderStyle-CssClass="visible-desktop">
<HeaderStyle CssClass="visible-desktop" HorizontalAlign="Right"></HeaderStyle>

<ItemStyle CssClass="visible-desktop" HorizontalAlign="Right"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Amount" DataField="Amount" ItemStyle-CssClass="visible-desktop"
HeaderStyle-CssClass="visible-desktop">
<HeaderStyle CssClass="visible-desktop"></HeaderStyle>

<ItemStyle CssClass="visible-desktop"></ItemStyle>
</asp:BoundField>
<%--<asp:CommandField ShowDeleteButton="True" ItemStyle-CssClass="visible-desktop" HeaderStyle-CssClass="visible-desktop" />--%>
</Columns>
</asp:GridView>

最佳答案

将此添加到您的 GridView

    <HeaderStyle CssClass="gridHeaderAlignRight" />
</asp:GridView>

在你的 CSS 文件中

.gridHeaderAlignRight {
text-align:right;
}

关于c# - 如何将 Gridview 标题对齐到右边?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28850800/

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