【问题标题】:How to add a sorting Image to a GridView Header while working with ObjectDataSource or EntityDataSource如何在使用 ObjectDataSource 或 EntityDataSource 时将排序图像添加到 GridView 标头
【发布时间】:2011-07-15 05:31:35
【问题描述】:

我想知道我们如何在使用ObjectDataSource 或实体框架时在GridView 标头中使用排序图像。因为它有直接调用功能,也有排序表达式。

那么,我如何使用GridView.RowCreated 事件并获取排序表达式来绑定排序图像?

【问题讨论】:

    标签: c# asp.net entity-framework gridview objectdatasource


    【解决方案1】:

    这是针对旧 ASP.NET 2.0 天的。 ASP.NET 4.0 允许我们将其指定为 asp:GridView 属性

    MSDN 链接

    1. SortedAscendingHeaderStyle
    2. SortedDescendingHeaderStyle

    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"

    您可能还想查看SortedAscendingCellStyleSortedDescendingCellStyle

    对于老式的方式,试试这个。 http://mattberseth.com/blog/2007/10/a_yui_datatable_styled_gridvie.html

    【讨论】:

    • 不幸的是,在GridView 中添加两个类和标签对我不起作用
    • 您能否将其添加为另一个问题。会看看的
    • 我使用了 RowCreated 方法,并且可以正常工作。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-03
    • 2015-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-28
    相关资源
    最近更新 更多