• 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);
                            }
                        }
    
                    }
    

      

  • 相关阅读:
    windows下面Nginx日志切割
    C#通过DocX创建word
    leetcode 189 Rotate Array
    leetcode 172 Factorial Trailing Zeroes
    leetcode 169 Majority Element 冰山查询
    leetcode 165 Compare Version Numbers
    leetcode 160 Intersection of Two Linked Lists
    【windows-》linux】SCP
    【设计】B端和C端区别
    【Flask】部署
  • 原文地址:https://www.cnblogs.com/gisbeginner/p/11775281.html
Copyright © 2020-2023  润新知