Hi Doug,
What's happening in your code is you are accessing the rows in the DataTable and not the rows in the DataView in your for loop.
Try this:
for(int myControl = 0; myControl < dv.Count; myControl++)
{
controlvalue = dv[myControl]["DataINeed"].ToString();
>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
-----------------------------------------
Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.comwww.prenia.comWeblog: blogs.prenia.com/cathi