下面代码显示在 C# 中如何将 DataView 转换为 DataTable 。在这里使用了 DataView 对象的 ToTable() 方法。让我们看一个 例子。
public static DataTable GetFilterData(DataTable table){
DataTable dataTable = table;
if (dataTable != null){
DataView dataView = new DataView(dataTable);
dataView.RowFilter = "Col1 == a"; // 一 些条件
dataTable = dataView.ToTable();
}
return dataTable;
}