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

      

  • 相关阅读:
    《杜教筛》
    《洛谷P4213 【模板】杜教筛(Sum)》
    《洛谷P1829 [国家集训队]Crash的数字表格 / JZPTAB》
    《纸牌问题》
    《洛谷P2522 [HAOI2011]Problem b》
    使用urlretrieve下载图片
    scrapy初探
    爬豆瓣电影名
    直接插入排序
    Windows python 3 安装OpenCV
  • 原文地址:https://www.cnblogs.com/gisbeginner/p/11775281.html
Copyright © 2011-2022 走看看