2
我無法弄清楚爲什麼SortedDescendingHeaderStyle-CssClass
和SortedAscendingHeaderStyle-CssClass
正在應用到排序我的GridView
標題?C#Gridview標題樣式不適用於排序
這是我的標記。我需要在代碼後面配置它嗎?
.ascending a
{
background: url(/images/asc.gif) right no-repeat;
display: block;
padding: 0 25px 0 5px;
}
.descending a
{
background: url(/images/desc.gif) right no-repeat;
display: block;
padding: 0 25px 0 5px;
}
<asp:GridView ID="gvOrderItems" runat="server" GridLines="None" CellSpacing="-1" AutoGenerateColumns="false" SortedAscendingHeaderStyle-CssClass="ascending"
AllowSorting="true" OnRowDataBound="gvOrderItems_RowDataBound" SortedDescendingHeaderStyle-CssClass="descending" OnSorting="gvOrderItems_Sorting" EnableViewState="true" AllowPaging="true" PageSize="10" OnPageIndexChanging="gvOrderItems_PageIndexChanging1">
<Columns>
<asp:BoundField DataField="OrderDate" HeaderText="Date" HeaderStyle-Font-Underline="true" HeaderStyle-ForeColor="White" ControlStyle-Font-Underline="true" DataFormatString="{0:dd/MM/yyyy}" SortExpression="OrderDate" />
<asp:BoundField DataField="OrderNumber" HeaderText="Order Number" HeaderStyle-Font-Underline="true" HeaderStyle-ForeColor="White" SortExpression="OrderNumber" />
<asp:BoundField DataField="SKUNumber" HeaderText="Product Number" HeaderStyle-Font-Underline="true" HeaderStyle-ForeColor="White" SortExpression="SKUNumber" />
<asp:BoundField DataField="OrderItemSKUName" HeaderText="Product Description" />
<asp:BoundField DataField="mtrx_Code2" HeaderText="Size" />
<asp:BoundField DataField="OrderItemUnitCount" HeaderText="OTY" />
<asp:BoundField DataField="OrderItemStatus" HeaderText="Status" />
</Columns>
<PagerStyle HorizontalAlign="Right" CssClass="cssPager"/>
</asp:GridView>
您是否嘗試對數據進行排序並檢查類是否被應用? –
您的GridView可能必須綁定到標記中的數據源才能自動工作。 – ConnorsFan
嗨Piyush類從來沒有得到應用時,我排序的數據?無論如何,我可以在排序事件中通過代碼添加它? – Kevin