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
- SortedAscendingHeaderStyle
- 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
精彩评论