2010-08-13 79 views

回答

2

您可以通過設置的RowFilter屬性這樣

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

here其他方式做過濾過濾行,由DataTable.Select功能

private void GetRowsByFilter(){ 
    DataTable myTable; 
    myTable = DataSet1.Tables["Orders"]; 
    // Presuming the DataTable has a column named Date. 
    string strExpr; 
    strExpr = "Date > '1/1/00'"; 
    DataRow[] foundRows; 
    // Use the Select method to find all rows matching the filter. 
    foundRows = myTable.Select(strExpr); 
    // Print column 0 of each returned row. 
    for(int i = 0; i < foundRows.Length; i ++){ 
     Console.WriteLine(foundRows[i][0]); 
    } 
} 

,你也可以得到過濾數據集

但是,所有這些方法都不會創建具有過濾數據的新DataSet,如果您需要它,則應該複製過濾行ma每當我猜...