【问题标题】:In Gridview header adding image along with text在 Gridview 标题中添加图像和文本
【发布时间】:2014-03-26 09:50:43
【问题描述】:

我有一个gridview,我想在其中将图像(小向上箭头或向下箭头)与文本一起添加到标题中,对应于它是升序还是降序排序。

我也搜索并找到了一些解决方案。但是我想要一个有效的解决方案来解决这个问题,stackoverflow 中的某个人可能已经知道了。请在这方面提供帮助。

【问题讨论】:

标签: c# asp.net .net gridview


【解决方案1】:

这可以通过将正确的 CSS 样式添加到您的 Gridview 来实现。

ASP.NET 标记

<asp:GridView ID="GridView1" runat="server" AllowSorting="True" DataSourceID="..." PageSize="5">
    <SortedAscendingHeaderStyle CssClass="sortasc" />
    <SortedDescendingHeaderStyle CssClass="sortdesc" />
</asp:GridView>

CSS

th.sortasc a  
{
    display:block; padding:0 4px 0 15px; 
    background:url(img/asc.gif) no-repeat;  
}

th.sortdesc a 
{
    display:block; padding:0 4px 0 15px; 
    background:url(img/desc.gif) no-repeat;
}

参考:http://blogs.msdn.com/b/scothu/archive/2010/08/28/gridview-with-sort-arrows-and-showing-header-when-empty.aspx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-10
    • 1970-01-01
    • 2022-09-28
    • 1970-01-01
    • 2020-10-03
    • 1970-01-01
    相关资源
    最近更新 更多