Dataview rowfilter does not work when looping the row

Posted on 2005-05-16
Last Modified: 2008-01-09
The generic code:

Dim dv As New DataView()
Dim dRow As datarow
Dim strHTML  As String

'Assuming I have ds sets here
'then create dv
dv = ds.Tables(0).DefaultView
dv.RowFilter = "ID = 1 OR ID is NULL"

For each drow in dv.Table.Rows
      -- Display here
      strHTML = strHML & drow("SomeFields")

Let's say rows in original dv (before filter) = 100 and after filter supposed to be 50.
In the for loop it is going to display 100 instead of 50 (after filter).

Filter only works if we bind data? not when actually loop thru it and display?
Question by:johndenny
    1 Comment
    LVL 24

    Accepted Solution

    Your loop should be

    for each row as datarowview in dv


    What you're doing right now is looking at the underlying table with no filters or sorts applied. Kind of defeats the whole purpose of the dataview! ;)

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now