• 排序上下箭头的是实现



    headertemplate中加一张UP.GIF和DOWN.GIF(就是升序,倒序的示意图)
    %@ Page Language="C#" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >

    <script runat="server">

       

        void GridView1_RowCreated(object sender, GridViewRowEventArgs e)

        {

            if (e.Row != null && e.Row.RowType == DataControlRowType.Header)

            {

                foreach (TableCell cell in e.Row.Cells)

                {

                    if (cell.HasControls())

                    {

                        LinkButton button = cell.Controls[0] as LinkButton;

                        if (button != null)

                        {

                            Image image = new Image();

                            image.ImageUrl = "default.gif";

                            if (GridView1.SortExpression == button.CommandArgument)

                            {

                                if (GridView1.SortDirection == SortDirection.Ascending)

                                    image.ImageUrl = "up.gif";

                                else

                                    image.ImageUrl = "down..gif";

                            }

                            cell.Controls.Add(image);

                        }

                    }

                }

            }

        }

           

    </script>

    <head id="Head1" runat="server">

        <title>Untitled Page</title>

    </head>

    <body>

        <form id="form1" runat="server">

        <div>

            <asp:GridView ID="GridView1" Runat="server" DataSourceID="SqlDataSource1" AllowSorting="True" AutoGenerateColumns="False" OnRowCreated="GridView1_RowCreated">

                <Columns>

                    <asp:BoundField HeaderText="customerid" DataField="CustomerID"></asp:BoundField>

                    <asp:BoundField HeaderText="companyname" DataField="CompanyName" SortExpression="CompanyName"></asp:BoundField>

                  

                </Columns>

            </asp:GridView>

            <asp:SqlDataSource ID="SqlDataSource1" Runat="server" SelectCommand="SELECT customerid,companyname FROM customers " ConnectionString="server=localhost;uid=sa;password=XXX;database=northwind">

            </asp:SqlDataSource>

        </div>

        </form>

    </body>

    </html>

  • 相关阅读:
    [Perl]Windows 系统 Unicode 文件名操作(新建、重命名、枚举、复制)全攻略
    [Perl]Can't link/include C library 'ft2build.h', 'freetype', aborting.
    ompparticles.cpp:(.text+0x322): undefined reference to `omp_set_num_threads'
    undefined reference to `omp_get_max_threads'
    使用MinGW 编译 iconv 库
    phpBB论坛 代码 语法高亮 模块 Codebox Plus
    最新版Mac系统(10.14.4) && Xcode(10.2.1) 无法使用dwarfdump 解析闪退的问题
    Xcode 8 打包教程
    Xcode 8.0无法注释的问题
    我的github地址,里边有一些拍照功能,选择照片功能的实现,还有一些其它的开源项目
  • 原文地址:https://www.cnblogs.com/lgzh3/p/715649.html
Copyright © 2020-2023  润新知