all groups > vb.net data > july 2004 >
You're in the

vb.net data

group:

Dataview and Rowfilter Question



Dataview and Rowfilter Question Brian W
7/21/2004 10:58:29 AM
vb.net data: I have found that when I create and populate a dataview, then set the
rowfilter property, that the rowfilter doesn't effect anything unless I bind
it to a control, if I iterate through the rows, the rowfilter doesn't filter
anything.

For example, I have a dataset, I push a table from the dataset to the
dataview, then set the rowfilter. I want to be able somehow to iterate
through the filtered rows ONLY, but if I iterate through, I get all rows
regardless of the rowfilter. Is there a better way to take a table from a
dataset and iterate through only the rows that I desire? I like the idea if
using a rowfilter to do it, it seems like a very simple way to do it, it
just isn't working as I would like it to. My desire would be to do this as
easily as setting the rowfilter property or something close to it.

Thanks for any help you can give me.

Brian W.

Re: Dataview and Rowfilter Question Jay B. Harlow [MVP - Outlook]
7/22/2004 8:24:36 AM
Brian,
Can you post a 10 to 20 lines of your code to demonstrate you problem?

I suspect you are iterating over the Table, you need to iterate over the
view itself.

When you iterate over a view, you see DataRowView objects, not DataRow
objects.

Something like:

Dim table As DataTable
Dim view As New DataView(table)
view.RowFilter = "id = 1"
For Each row As DataRowView in view
' only rows with id =1 found
Next

Hope this helps
Jay

[quoted text, click to view]

Re: Dataview and Rowfilter Question Brian W
7/22/2004 9:11:26 AM
You are correct, I am iterating through the table, i wasn't sure how to
iterate through the view. I believe you may have answered my question. I
will give it a try later today.

Thanks for your help.

Brian W.


[quoted text, click to view]

AddThis Social Bookmark Button