How can I find out the the rows filtered by the dataview.Rowfitler ?

Posted on 2009-05-13
Last Modified: 2012-05-06

when I set a dataview with a Rowfilter, can I find out somehow what is the filtered data?

my table:

1  mary
2 michael
3 hans
4 georg

my filter:

dataview.Rowfilter = " Name = ' michael ' ";

How can I retrieve the other 3 names without using the Rowfilter again like this:

dataview.Rowfilter = " Name <> 'michael';

HOpe the question is clear :)

Question by:MSFanboy
  • 4
  • 2

Expert Comment

ID: 24378315
You can ..... Loop through the rows in dataview.Table and pick out the ones that aren't in your filtered dataview.


Create a second dataview and create the opposite filter on that instead.

Author Comment

ID: 24393654
ah bad I told you crap...
requirements have changed actually again:

I want to enumerate through the dataview to get the each value in every row in the filtered dataview.

foreach (DataRowView row in dataview)
    row.value doesnt work
    row.Row[3]. doesnt work // I want to get the value in the 4th column of the actual row of my dataview

How can I enumerate through all Rows of the dataview and get a value of each row in a certain column?
I have to compare the one value in a dataview`s [row,column] with the value of a datareader...


Author Comment

ID: 24393678
I also tried this:

foreach (DataRowCollection row in dataview.Table.Rows)
    row. // no value or cell I get :/

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.


Author Comment

ID: 24394201
for (int j = 0; i < dataview.Count; i++)
                          var articlenumber = dataview[j].Row[3].ToString();

found a sample in vb and changed it to c#, pretty stupid that there is no Row.Value or Cell.Value as someone could expect it.

Accepted Solution

wellhole earned 500 total points
ID: 24395292
foreach (DataRowView row in dataview)
  row[3]          <--------- thats the value in the 4th column

In your above sample, it'll be best if you don't mix up i and j......

Author Comment

ID: 24396534
ah damn above I have a for loop with i or j, thx that you saw the error and for the snippet

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 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

9 Experts available now in Live!

Get 1:1 Help Now