Solved

Filter child rows from DataView

Posted on 2008-10-25
5
922 Views
Last Modified: 2013-12-17
I have a dataset with two tables (Parent) and (child)

I have added a relation between thest two tables
dsPO.Relations.Add("Parent2Child",
dsPO.Tables("Parent").Columns("ID"),
dsPO.Tables("Child").Columns("ID"))

I filtered Inventory table for price>0
dsPO.Tables("Parent").DefaultView.RowFilter = "Price>0"

and assign to a datagrid
grdDetails.DataSource = dsPO.Tables("Parent").DefaultView

My question is is there any way filtering child rows. I want to filter for
Strike > 10 in Child table. When I put .
dspo.Tables("Child").DefaultView.RowFilter ="Strike > 10'"
Datagrid doesn't change or filter child rows.
0
Comment
Question by:97WideGlide
  • 3
  • 2
5 Comments
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22806806
do you have 2 data grids or only one data grid
if there are 2 data grids one showing the parent and the other children then in that case when a parent is selected (index changed) you need to do a child row filter for that parent and then rebind the second grid
0
 
LVL 8

Author Comment

by:97WideGlide
ID: 22807433
I have only one data grid which displays the vew in hierarchical fashion.  
When you say "do a child row filter" do you mean to iterate through all the parent rows requesting the related childview of each parent row and filtering ?  I was trying to do it that way but my tables are pretty large (Parent 5K and Child 300K) and this was taking a prohibitively long time.  

Also, I need to filter the entire child table at once because I also need to present a cumulative total of all unfiltered children.  
0
 
LVL 26

Assisted Solution

by:Anurag Thakur
Anurag Thakur earned 500 total points
ID: 22807638
i dont think (my view point) what you are trying to achieve is a good approach

in such a circumstances i would have had a gridview in which i will show all the parents and when i select a parent i will reload the children in a details view
the only drawback that i see is that there is going to be a postback on every parent selected
if such is done then large data problem is solved.
0
 
LVL 8

Author Comment

by:97WideGlide
ID: 22809906
Keep in mind that I will be processing this data so it is not just a question of how best to display it.

So, with that in mind, using your solution, how will I get things like a count of all of the rows which made it through the child filter?

For example, consider a parent table of 5K junkyards and a child table of 300K salvage parts in those junkyards.  I want to be able to filter the junkyards to get say, all located West of the Missippi.  Then I want to further filter the child table to limit the parts to all those valued more than say, $1000 or those which cost less than $30 to ship, or both.  At any given time I want to have a count of the total number of junkyards and parts that remain unfiltered.  
0
 
LVL 8

Accepted Solution

by:
97WideGlide earned 0 total points
ID: 22817532
Found a solution.  
A DataViewManager solves this problem very well.  Just remember to rebind the DVM after filtering or sorting so that the updates are available to your grid.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), 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, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

22 Experts available now in Live!

Get 1:1 Help Now