Solved

Filter child rows from DataView

Posted on 2008-10-25
5
920 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 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

19 Experts available now in Live!

Get 1:1 Help Now