Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Iterating through records of a DataView with a filter
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Iterating through records of a DataView with a filter
Miscellaneous
Thread ID:
00726538
Message ID:
00726538
Views:
39
All,

I have a DataSet which has data that needs conditional processing.

I have the data in a ViewState
DataSet ds = (DataSet)ViewState["Components"];
DataView dv = new DataView(ds.Tables[0]);
The DataSet has 18 records. I then establish a filter
dv.RowFilter = "type <> 'RepeatControl'";
And dv.Count is correctly set to 16.

However, if I am processing through my DataView:
for(int myControl = 0; myControl < dv.Count; myControl++)
{
   controlvalue = dv.Table.Rows[myControl]["DataINeed"].ToString();
But what happens is that I can still access rows of the View which do not meet my filter condition (which happen to be rows 0 and 1 in this case). What do I need to do to make this work correctly? dv.Count is set to 16, but I can still look at dv.Table.Row[16] and dv.Table.Row[17].

I do notice that if I set my filter to
dv.RowFilter = "type = 'RepeatControl'";
dv.Count is set to 2 and I cannot access any data above dv.Table.Row[1]?

Confused,
Doug
Douglas Osborne
Don't spend your life just wishing - http://www.AllGiftRegistry.com
Next
Reply
Map
View

Click here to load this message in the networking platform