开发者

How to add a sorting Image to a GridView Header while working with ObjectDataSource or EntityDataSource

I want to know how can we use sorting image inside GridView开发者_C百科 header while we use ObjectDataSource or Entity Framework. Because that has direct calling feature and also having sorting expression.

So, how can i use GridView.RowCreated event and get the sort expression to bind the sorting image?


That was for older ASP.NET 2.0 days. ASP.NET 4.0 allows us to specify it as a asp:GridView property

MSDN Links

  1. SortedAscendingHeaderStyle
  2. SortedDescendingHeaderStyle

GridView Markup

<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; }

Please note that the asp:GridView has been assigned CssClass="datatable".

You might also want to check out SortedAscendingCellStyle and SortedDescendingCellStyle

For old fashioned way, try this. http://mattberseth.com/blog/2007/10/a_yui_datatable_styled_gridvie.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜