C # Converting DataView to Table (DataTable) in .NET 1.1

I have a dataview on which I have set the rowfilter:

DataView dv = ds.Tables[0].DefaultView;

dv.RowFilter = "here my filter";

      

After filtering the data, I want to convert it to DataTable. I know this is possible in .NET 2.0 and up using this:

Datatable result  = dv.ToTable();

      

But how do you do this in .NET 1.1?

+3


source to share


2 answers


How about this workaround using Datatable Select



DataTable dt = ds.Tables[0];
DataTable filterdt = dt.Clone(); //Available from .Net 1.1

//Datatable Select Available from .Net 1.1              
DataRow[] filterRows = dt.Select("here you filter"); 



 //Loop filterRows[] and import to filterdt Datatable

  foreach (DataRow filterRow in filterRows)
                filterdt.ImportRow(filterRow); //Datatable Import row Available from .Net 1.1

      

0


source


This works in .NET 1.1 because the enumerator DataView

only returns filtered strings:



DataTable table = dv.Table.Clone();
foreach (DataRowView rowView in dv)
    table.ImportRow(rowView.Row);

      

0


source







All Articles