zoukankan      html  css  js  c++  java
  • 排序上下箭头的是实现


    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>

  • 相关阅读:
    Codeforces Round #518 (Div. 1) Computer Game 倍增+矩阵快速幂
    BZOJ2756 [SCOI2012]奇怪的游戏 最大流
    Codeforces Global Round 1 (CF1110) (未完结,只有 A-F)
    [AtCoder] NIKKEI Programming Contest 2019 (暂缺F)
    [AtCoder] Yahoo Programming Contest 2019
    Codeforces Round #538 (Div. 2) (CF1114)
    [BZOJ3625][Codeforces Round #250]小朋友和二叉树 多项式开根+求逆
    [BZOJ2341][Shoi2011]双倍回文 manacher+std::set
    [BZOJ4278] [ONTAK2015]Tasowanie 贪心+后缀数组
    [BZOJ3451] Tyvj1953 Normal 点分治+FFT
  • 原文地址:https://www.cnblogs.com/lgzh3/p/715649.html
Copyright © 2011-2022 走看看