• GridView排序Sorting事件


    1、if (!IsPostBack)
                {
                    DBindFilter();
                    this.gvwData.Attributes.Add("SortExpression", "HouseID");
                    this.gvwData.Attributes.Add("SortDirection", "ASC");
                    GridViewDataBind();
                    chklColumns.Visible = !IsPostBack;  //设置“显示字段”的下拉属性
                }
                else
                {
                    chklColumns.Visible = IsPostBack;   //设置“显示字段”的下拉属性
                }

    2、// 获取GridView排序数据列及排序方向
                    string sortExpression = this.gvwData.Attributes["SortExpression"];
                    string sortDirection = this.gvwData.Attributes["SortDirection"];
                    if ((!string.IsNullOrEmpty(sortExpression)) && (!string.IsNullOrEmpty(sortDirection)))
                    {
                        table.DefaultView.Sort = string.Format("{0} {1}", sortExpression, sortDirection);
                    }
                    gvwData.DataSource = table.DefaultView;
                    gvwData.DataBind();

    3、//排序
            protected void gvwData_Sorting(object sender, GridViewSortEventArgs e)
            {
                //获取排序数据列
                string sortExpression = e.SortExpression.ToString();
                //假定为排序方向为“顺序”
                string sortDirection = "ASC";
                // “ASC”与事件参数获取到的排序方向进行比较,进行GridView排序方向参数的修改
                if (sortExpression == this.gvwData.Attributes["SortExpression"])
                {
                    //获得下一次的排序状态
                    sortDirection = (this.gvwData.Attributes["SortDirection"].ToString() == sortDirection ? "DESC" : "ASC");
                }
                // 重新设定GridView排序数据列及排序方向
                this.gvwData.Attributes["SortExpression"] = sortExpression;
                this.gvwData.Attributes["SortDirection"] = sortDirection;

                this.GridViewDataBind();
            }

  • 相关阅读:
    rust 宏
    umi 调试
    rust 编译器工作流
    rust 神奇的特质
    rust 生命周期2
    rust 函数-生命周期
    rust 九九乘法表
    rust 代码生成选项
    rust 编码模式
    恢复到版本并销毁之后的git提交记录
  • 原文地址:https://www.cnblogs.com/jsping/p/2564186.html
Copyright © 2020-2023  润新知