I am using the following code to filter a DataView and then put the
dataview back into a DataSet. I've verified that strFilter contains
683 values.

The dataview initially has 1306 records before the filter. However,
the resulting dataset that comes out has all 1306 rows.

How is this possible since I'm filtering on 683 unique values?

I'd appreciate any help

-Tim

//create a dataview for the dataset
//DataTable oDT = oDS.Tables["Results"];
DataView oDV = new DataView(oDS.Tables["Results"]);

DataTable oDT = new DataTable();
try
{
if(strFilter != "")
{
//filter the dataview with the previous work ids

oDV.RowFilter = "WorkID IN (" + strFilter + ")";
}
}
catch(Exception err)
{
Response.Write("Error: " + err.Message.ToString());
}

//Convert the DataView back to a DataSet
oDT = oDV.Table.Copy();
oDS = new DataSet(oDV.Table.TableName);
oDS.Tables.Add(oDT);

Re: DataView Filter Not working by William

William
Mon Sep 15 12:54:18 CDT 2003

You are copying the source table and adding the source table to the new
dataset. Remember that a Datatview is like a virtual table because it's
based on a table.

If you iteratively went through the dataview and added it to a table row by
row, then added the table to the dataset, you'll have only what was
filtered. But copying the whole table in is going to give you back the
whole table.

In most instances though, having the datatable in a dataset should
suffice...copying it to another one, in many cases probably isn't necessary.

HTH,

Bill
"Tim" <tim.cavins@sitel.com> wrote in message
news:dc9a9e04.0309150939.d7e8b5a@posting.google.com...
> I am using the following code to filter a DataView and then put the
> dataview back into a DataSet. I've verified that strFilter contains
> 683 values.
>
> The dataview initially has 1306 records before the filter. However,
> the resulting dataset that comes out has all 1306 rows.
>
> How is this possible since I'm filtering on 683 unique values?
>
> I'd appreciate any help
>
> -Tim
>
> //create a dataview for the dataset
> //DataTable oDT = oDS.Tables["Results"];
> DataView oDV = new DataView(oDS.Tables["Results"]);
>
> DataTable oDT = new DataTable();
> try
> {
> if(strFilter != "")
> {
> //filter the dataview with the previous work ids
>
> oDV.RowFilter = "WorkID IN (" + strFilter + ")";
> }
> }
> catch(Exception err)
> {
> Response.Write("Error: " + err.Message.ToString());
> }
>
> //Convert the DataView back to a DataSet
> oDT = oDV.Table.Copy();
> oDS = new DataSet(oDV.Table.TableName);
> oDS.Tables.Add(oDT);