Solved

Filter child rows from DataView

Posted on 2008-10-25
5
928 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
[X]
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
  • 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

735 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