Urgent:[Iterating Rows after Applying RowFilter in DefaultView]

Urgent:[Iterating Rows after Applying RowFilter in DefaultView]

Post by vss » Thu, 14 Feb 2002 10:17:59



Hi,
Is there some way I can get hold of the filtered Rows from
the DataSet, except for Binding?
I want to iterate through the filtered rows (Rows filtered
by using RowFilter in the DefaultView of a Table in the
DataSet).
Thanks and Regards,
vss
 
 
 

Urgent:[Iterating Rows after Applying RowFilter in DefaultView]

Post by Grif » Fri, 15 Feb 2002 05:25:22


Try something like this (this example is using a typed dataset, but it
doesn't have to - they're just clearer programatically):

TypedDataSet ds = new TypedDataSet();
//Fill the dataset
// ...
//...
string filter = "Column2 = '3'";
ds.Table1.DefaultView.RowFilter = filter;
foreach (TypedDataSet.Table1Row r in ds.Table1.DefaultView)
{
    lbListBox.Items.Add(r.column1);

}



Quote:> Hi,
> Is there some way I can get hold of the filtered Rows from
> the DataSet, except for Binding?
> I want to iterate through the filtered rows (Rows filtered
> by using RowFilter in the DefaultView of a Table in the
> DataSet).
> Thanks and Regards,
> vss


 
 
 

Urgent:[Iterating Rows after Applying RowFilter in DefaultView]

Post by vss » Fri, 15 Feb 2002 06:23:19


Since I found out. Just an update to the query I posted.

Get the iterator from the DefaultView after applying the RowFilter.
Following is the code:

------------------------------------------------------------------

IEnumerator ie = ds.Tables[0].DefaultView.GetEnumerator();

while(ie.MoveNext()){

    DataRowView dr = (DataRowView)ie.Current;

    string type =dr.Row["ATTRIBTYPE"].ToString();

    Response.Write(type);

Quote:}

-----------------------------------------------------------------

Thanks and Regards
vss