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接口自动化基础框架结构 ——分层
    常见的布局实现,以及响应式布局技巧。
    google closure继承模块三:goog.base()源码分析
    google closure--继承模块二:goog.base()demo分析
    google closure--继承模块一:goog.inherits()
    项目中踩过的坑之-sessionStorage
    .NET/C#使用NPOI操作Excel
    WEB免费打印控件推荐
    Linux下部署ASP.NET项目
    Hibernate 查询方式(HQL/QBC/QBE)汇总
  • 原文地址:https://www.cnblogs.com/gisbeginner/p/11775281.html
Copyright © 2011-2022 走看看