我正在尝试将网格视图的标题对齐但是它不起作用,我甚至尝试了中心等,但它们都没有工作,但它适用于项目。我想将列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>
答案 0 :(得分:2)
将其添加到GridView
<HeaderStyle CssClass="gridHeaderAlignRight" />
</asp:GridView>
在CSS文件中
.gridHeaderAlignRight {
text-align:right;
}
答案 1 :(得分:0)
这里的代码是正确的
<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>
我怀疑这个班级visible-desktop
或其他是HorizontalAlign="Right"
无效的原因。所以在FireBug(或同等版本)中进行调查。