求教 我现在导入和现实Excel没有问题了 我想要的是 在现实出来的DataTable中 进行条件查询 如何实现?

解决方案 »

  1.   

    dt.AsEnumerable().Where(m=>m.Field<string>("col1")=="男")
      

  2.   

    通过 RowFilter进行过滤
    private void MakeDataView() 
      {
          DataView view = new DataView();
      
          view.Table = DataSet1.Tables["Suppliers"];
          view.AllowDelete = true;
          view.AllowEdit = true;
          view.AllowNew = true;
          view.RowFilter = "City = 'Berlin'";
          view.RowStateFilter = DataViewRowState.ModifiedCurrent;
          view.Sort = "CompanyName DESC";
      
          // Simple-bind to a TextBox control
      
          Text1.DataBindings.Add("Text", view, "CompanyName");
      }
      
      

  3.   

    可以使用Linq   也可以用RowFilter  很多种方法