1
我想知道在我們使用ObjectDataSource
或實體框架時如何在GridView
標頭中使用排序圖像。因爲它具有直接調用功能並且還具有排序表達式。如何在使用ObjectDataSource或EntityDataSource的同時將排序圖像添加到GridView標題
那麼,如何使用GridView.RowCreated
事件並獲取排序表達式來綁定排序圖像呢?
我想知道在我們使用ObjectDataSource
或實體框架時如何在GridView
標頭中使用排序圖像。因爲它具有直接調用功能並且還具有排序表達式。如何在使用ObjectDataSource或EntityDataSource的同時將排序圖像添加到GridView標題
那麼,如何使用GridView.RowCreated
事件並獲取排序表達式來綁定排序圖像呢?
這是舊的ASP.NET 2.0天。 ASP.NET 4.0允許我們將其指定爲一個asp:GridView
財產
MSDN鏈接
GridView的標記
<SortedAscendingHeaderStyle CssClass="sortasc" />
<SortedDescendingHeaderStyle CssClass="sortdesc" />
CSS
.datatable th
{
font-size:12px;
font-weight:bold;
letter-spacing:0px;
text-align:left;
padding:2px 4px;
color:#333333;
border-bottom:solid 2px #bbd9ee;
}
.datatable th a
{
text-decoration:underline;
padding-right:18px;
color:#000;
}
.datatable th.sortasc a { background:url(../Images/asc.gif) right center no-repeat; }
.datatable th.sortdesc a { background:url(../Images/desc.gif) right center no-repeat; }
請注意asp:GridView
已分配CssClass="datatable"
。
你可能也想看看SortedAscendingCellStyle和SortedDescendingCellStyle
對於老式方法,試試這個。 http://mattberseth.com/blog/2007/10/a_yui_datatable_styled_gridvie.html
在'GridView'中添加兩個類和標記不能爲我工作,不幸的是 – Si8
您可以添加另一個問題。將看看它 – naveen
我用RowCreated方法去,我有它的工作。謝謝 – Si8