thisAdapter.Fill(thisDataSet,"tb");
DataTable thisTable = thisDs.Tables["tb"];
DataView thisView = new DataView(thisTable); //创建DataView对象
thisView.RowFilter = ....;
DataGrid.DataSource = thisView;
...
a,使用sort属性对数据进行排序
thisView.Sort = "ProductName ASC";
or
thisView.Sort = "Age ASC , Name DESC";
b,使用RowFilter属性对数据过滤
thisView.RowFilter =
"ID = 10";
"Num <= 10";
"Date > 1/1/1999 and Date <= 2/2/2005";
"Product in ('apple','cat','table')"
"Text like = '*son'";
注:使用的各条件可用 and 继续添加,在使用 *** in ('','','') 时,注意括号内的项目不易过多,估计能支持十几个.
1,按一对x,y坐标筛选数据 x1 x2 y1 y2
thisView .RowFilter =
"HZBY >= '" + x1 + "' and HZBY <= '" + x2 + "' and ZZBX >= '" + y1 + "' and ZZBX <= '" + y2 + "'";
2,由数组生成筛选条件
//格式为 DataView.Filter = "GZDYMC IN ('job','tree',work')";
string strView = "GZDYMC in (";
int ii = 0;
while(ii < ColTrueNames.Count)
{
strView += "'" + ColTrueNames[ii] + "',";
ii++;
}
strView += "'null')";
thisView.RowFilter = strView;
source: http://www.cnblogs.com/tigercopy/archive/2009/06/17/1505082.html
本文介绍了如何使用DataView对象进行数据筛选和排序的方法。包括使用RowFilter属性设置复杂的筛选条件,如按ID、日期范围及字符串匹配等,并演示了如何通过Sort属性实现字段的升序或降序排列。
1520

被折叠的 条评论
为什么被折叠?



