Solved

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

Posted on 2009-05-13
6
299 Views
Last Modified: 2012-05-06
Hello,

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

my table:

id.Name
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 :)


0
Comment
Question by:MSFanboy
  • 4
  • 2
6 Comments
 
LVL 9

Expert Comment

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

or

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

Author Comment

by:MSFanboy
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...


0
 

Author Comment

by:MSFanboy
ID: 24393678
I also tried this:

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

0
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.

 

Author Comment

by:MSFanboy
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.
0
 
LVL 9

Accepted Solution

by:
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......
0
 

Author Comment

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Service Controller 1 28
Hey!! 5 37
VS 2013 installer,  Install, Update and uninstall via SCCM 6 26
VS2010 Build fails to install 14 39
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

830 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