Solved

DataViewManager to filter parent and child relation

Posted on 2004-08-30
7
1,419 Views
Last Modified: 2008-01-09
Hi Experts,

Here is my dataset:
datatableParent : columnFileId, columnFileName
datatableChild : columnFileId, columnPathId
                               
I want to filter the parent table to get only files in the path I want.
So with my dataviewmanager, I filter like this:
dataViewManager.DataViewSettings[datatablechild].RowFilter="columnPathId='5' "; for example.
But it seems to filter only the child and not the parent.
Any Idea to filter rows in a parent table depending on criteria met in a child table ?

Thanks in advance for your answers.

0
Comment
Question by:noulouk
  • 5
  • 2
7 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11932724
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11932780
whoops im backwards ... You can't do it directly through rowfilters because you can only use aggregates ...

PARENT/CHILD RELATION REFERENCING

A parent table may be referenced in an expression by prepending the column name with Parent. For example, the Parent.Price references the parent table's column named Price.

A column in a child table may be referenced in an expression by prepending the column name with Child. However, because child relationships may return multiple rows, you must include the reference to the child column in an aggregate function. For example, Sum(Child.Price) would return the sum of the column named Price in the child table.

If a table has more than one child, the syntax is: Child(RelationName). For example, if a table has two child tables named Customers and Orders, and the DataRelation object is named Customers2Orders, the reference would be:

Instead you would use ... GetParentRows which will get all of the parents for the records in your view http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdatadatarowclassgetparentrowstopic.asp
0
 
LVL 9

Author Comment

by:noulouk
ID: 11932813
Thanks for reply, but I'm not agree with you. The best I can do is to use getparentrows method because the child view is filtered as I want (but the parent view not), so with getparentrows methods I'll be able to retrieve my rows when I filter the child rows.
I want to know if another solution is available and more easy than mine. For example, a solution that filters rows in a parent view depending on criteria met in a child view ?
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 11932856
you cannot use the children in the rowfilter per the information I posted (they are only available within aggregate functions)
0
 
LVL 9

Author Comment

by:noulouk
ID: 11932861
I find your post after posting mine. Now I'm agree with you.

Do you think it's possible ?
" For example, a solution that filters rows in a parent view depending on criteria met in a child view ?  "
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11932884
if there is to be only 1 row in the child sure ... you could filter off the average aggregate of the children ...
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11933075
the average of { 8 } is 8 :)
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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