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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 :/

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity AddWithValue when using IN condition 7 42
abstract class C# 1 44
Problem to copy file 14 82
Selenium and Xpath 4 65
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 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