How to get row count of a DataRelation?

P

PeterZ

If you have two dataTables and a dataRelation how would you get the row
count of the dataRelation?

Lets use the obligatory simpleton example - A strongly typed dataset with an
Authors and Books table and a dataRelation between the two.

ie:
myDataSet.Authors
myDataSet.Books
myDataSet.relBooksByAuthor

Now you bind a listbox to the Authors and a dataGrid to the dataRelation.
The grid now shows only the books by the currently selected author.
Mindblowing stuff I know, but just try to stay with me on this one :)

Ok, now how would you get the row count of the books by the currently
selected author? Surely this must be a property of the dataRelation object?
I mean it must know how many rows its filtering at any given time?

I tried looking for a Rows.Count property in a dataRelation but there isn't
any, ie:

myDataSet.relations["relBooksByAuthor"].Rows.Count? not there!

If I get the row count of myDataSet.Books.Rows.Count I always get the total
number in the whole table, not the filtered count.

Surely this must be a nobrainer?
Can anyone shed light?


Thanks,
PeterZ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top