zoukankan      html  css  js  c++  java
  • c# dataTable 排序

     if(columnBindingName== "modifyfrequency")
                    {
                       
                        DataTable dt = this.dgvMyIndex.DataSource as DataTable;
                        EnumerableRowCollection<DataRow> dayquery =
        from order in dt.AsEnumerable()  where order.Field<string>("modifyfrequency") == "日" 
        select order;
                        EnumerableRowCollection<DataRow> weekquery =
      from order in dt.AsEnumerable()
      where order.Field<string>("modifyfrequency") == "周"
      select order;
                        EnumerableRowCollection<DataRow> xunquery =
    from order in dt.AsEnumerable()
    where order.Field<string>("modifyfrequency") == "旬"
    select order;
                        EnumerableRowCollection<DataRow> halfMonthquery =
    from order in dt.AsEnumerable()
    where order.Field<string>("modifyfrequency") == "半月"
    select order;
                        EnumerableRowCollection<DataRow> monthquery =
      from order in dt.AsEnumerable()
      where order.Field<string>("modifyfrequency") == "月"
      select order;
                        EnumerableRowCollection<DataRow> quaterquery =
     from order in dt.AsEnumerable()
     where order.Field<string>("modifyfrequency") == "季度"
     select order;
                        EnumerableRowCollection<DataRow> halfYearquery =
    from order in dt.AsEnumerable()
    where order.Field<string>("modifyfrequency") == "半年"
    select order;
                        EnumerableRowCollection<DataRow> Yearquery =
    from order in dt.AsEnumerable()
    where order.Field<string>("modifyfrequency") == "年"
    select order;
                        EnumerableRowCollection<DataRow> budingqiquery =
    from order in dt.AsEnumerable()
    where order.Field<string>("modifyfrequency") == "不定期"
    select order;
                        EnumerableRowCollection<DataRow> daidingquery =
    from order in dt.AsEnumerable()
    where order.Field<string>("modifyfrequency") == "待定"
    select order;
                        DataTable newDataTable = dt.Clone();
                        if (sortMode=="asc")
                        {
                           
    
                            foreach (var row in dayquery)
                            {
                                newDataTable.Rows.Add(row.ItemArray);
                            }
                            foreach (var row in weekquery)
                            {
                                newDataTable.Rows.Add(row.ItemArray);
                            }
                            foreach (var row in xunquery)
                            {
                                newDataTable.Rows.Add(row.ItemArray);
                            }
                            foreach (var row in halfMonthquery)
                            {
                                newDataTable.Rows.Add(row.ItemArray);
                            }
                            foreach (var row in monthquery)
                            {
                                newDataTable.Rows.Add(row.ItemArray);
                            }
                            foreach (var row in quaterquery)
                            {
                                newDataTable.Rows.Add(row.ItemArray);
                            }
                            foreach (var row in halfYearquery)
                            {
                                newDataTable.Rows.Add(row.ItemArray);
                            }
                            foreach (var row in Yearquery)
                            {
                                newDataTable.Rows.Add(row.ItemArray);
                            }
                            foreach (var row in budingqiquery)
                            {
                                newDataTable.Rows.Add(row.ItemArray);
                            }
                            foreach (var row in daidingquery)
                            {
                                newDataTable.Rows.Add(row.ItemArray);
                            }
                        }
    
                    }
    

      

  • 相关阅读:
    Python--__init__方法
    Python--面向对象编程
    用R语言对NIPS会议文档进行聚类分析
    docker oracle install
    java 删除字符串左边空格和右边空格 trimLeft trimRight
    mysql 表名和字段、备注
    docker学习
    shell爬虫
    shell 解析json
    SecureCRT 7.1.1和SecureFx key 亲测可用
  • 原文地址:https://www.cnblogs.com/gisbeginner/p/11775281.html
Copyright © 2011-2022 走看看