zoukankan      html  css  js  c++  java
  • DataGrid排序中加入方向标识核心代碼

    在DataGrid中根據排序方向,在HeaderText加入排序方向.代碼如下:
      /// <summary>
        
    /// 得到數據,根據分頁Index及排序ID綁定數據
        
    /// </summary>
        
    /// <param name="iPageIndex">頁碼</param>
        
    /// <param name="sSortID">排序的ID</param>
        private void Copmmon(int iPageIndex,string sSortID)
        {        
            
    string sDeptID = Request.QueryString["strDeptID"];
            
    string sQuery = "select UioID,UioName from Hp_UserInfo where UioDeptID='{0}'";
            sQuery 
    = string.Format(sQuery, sDeptID);
            
    if (!string.IsNullOrEmpty(sSortID) && sSortID != "")
            {
                
    string sSortDirection = "DESC"//为排序方向变量赋初值
                if (sSortDirection == grdRequireList.Attributes["GrdSortDirection"])
                {
                    
    //获得下一次的排序状态
                    sSortDirection = (grdRequireList.Attributes["GrdSortDirection"].ToString() == sSortDirection ? "ASC" : "DESC");
                }
                grdRequireList.Attributes[
    "GrdSortDirection"= sSortDirection;
                
    string sOrder = " Order by {0} {1}";
                sOrder 
    = string.Format(sOrder, sSortID, sSortDirection);
                sQuery 
    = sQuery + sOrder;

                
    //排序图标
                char[] cArray = new char[] { '''' };
                
    //加方向标
                for (int iSor = 0; iSor < grdRequireList.Columns.Count; iSor++)
                {
                    
    if (grdRequireList.Columns[iSor].SortExpression.ToString() == sSortID)
                    {
                        
    int iColindex = iSor;
                        
    if (sSortDirection=="DESC")
                        {
                            grdRequireList.Columns[iSor].HeaderText 
    = grdRequireList.Columns[iSor].HeaderText.Trim(cArray);
                            grdRequireList.Columns[iColindex].HeaderText 
    = grdRequireList.Columns[iColindex].HeaderText + "";
                        }
                        
    else
                        {
                            grdRequireList.Columns[iSor].HeaderText 
    = grdRequireList.Columns[iSor].HeaderText.Trim(cArray);
                            grdRequireList.Columns[iColindex].HeaderText 
    = grdRequireList.Columns[iColindex].HeaderText + "";
                        }
                       
                    }
                    
    else
                    {
                        grdRequireList.Columns[iSor].HeaderText 
    = grdRequireList.Columns[iSor].HeaderText.Trim(cArray);
                    }
                }
            }       

            DataView dvApplyers 
    = TDAIClient.BusinessDB.GetDataView(sQuery);
            
    if (dvApplyers.Count > 0)
            {
                
    //执行查询
                grdRequireList.PageSize = 500;
                grdRequireList.DataSource 
    = dvApplyers;
                grdRequireList.CurrentPageIndex 
    = iPageIndex;
                grdRequireList.DataBind();
            }
        }


  • 相关阅读:
    Unity之串口通信(基于三姿态传感器)
    Unity3d win7协议多点触控
    大大的蛋项目 第二篇 第三关
    大大的蛋项目
    Unity3d 调用C++的DLL
    有梦想的小鸟
    【Unity3D插件】NGUI屏幕自适应 .
    【Unity3d】使GUI适应屏幕分辨率
    unity自动保存项目
    BloomFilter——大规模数据处理利器
  • 原文地址:https://www.cnblogs.com/scottckt/p/1352026.html
Copyright © 2011-2022 走看看