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 ('','','') 时,注意括号内的项目不易过多,估计能支持十几个.
eg;
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;
想要了解某人的话,首先要知道对方反感什么.