/// <summary> /// /// </summary> /// <param name="dt"></param> /// <param name="strWhere">筛选的条件</param> /// <returns></returns> public DataTable SreeenDataTable(DataTable dt,string strWhere) { if(dt.Rows.Count<=0)return dt; //当数据为空时返回 DataTable dtNew = dt.Clone(); //复制数据源的表结构 DataRow[] drs = dt.Select(strWhere); //strWhere条件筛选出需要的数据! if (drs.Length > 0) //判断是否存在符合的数据、为下面copy,不然报错 dtNew = drs.CopyToDataTable(); //copy到新的datatable中! return dtNew; }
时间: 2024-11-19 14:31:32