C# 如何从数据集筛选值返回数据集

C# 如何从数据集筛选值返回数据集,c#,C#,我想从静态数据集中返回数据集筛选器 有可能吗?您可以按功能筛选行 private void GetRowsByFilter(){ 数据表myTable; myTable=DataSet1.Tables[“Orders”]; //假定DataTable有一个名为Date的列。 字符串strExpr; strExpr=“日期>'1/1/00'; DataRow[]foundRows; //使用Select方法查找与筛选器匹配的所有行。 foundRows=myTable.Select(strExpr

我想从静态数据集中返回数据集筛选器

有可能吗?

您可以按功能筛选行

private void GetRowsByFilter(){
数据表myTable;
myTable=DataSet1.Tables[“Orders”];
//假定DataTable有一个名为Date的列。
字符串strExpr;
strExpr=“日期>'1/1/00';
DataRow[]foundRows;
//使用Select方法查找与筛选器匹配的所有行。
foundRows=myTable.Select(strExpr);
//打印每个返回行的第0列。
for(int i=0;i
您还可以通过如下设置RowFilter属性来获取筛选数据集

ds.Tables[<table name>].DefaultView.RowFilter = "ProductId=5"
ds.Tables[].DefaultView.RowFilter=“ProductId=5”
寻找其他方法进行过滤

但所有这些方法都不会使用过滤数据创建新的数据集,如果需要,应该手动复制过滤后的行

ds.Tables[<table name>].DefaultView.RowFilter = "ProductId=5"