tags:

views:

435

answers:

1

Hi,

I have a GridView control which has a DataSet as a datasource. The dataset contains a parent child relation between two tables, Publications and Owner. When iterating through the dataset creating each row of the gridview, how do I access the data in the child table so that I can display it?

Thanks R.

A: 

R,

I've been looking around for a best approach to this myself today. If it was a low-traffic site where performance didn't matter, you could grab the data from the parent table first and then use inline method(s) passing the ID to grab the child data. Not very efficient though.

Another approach would be to create a class with properties representing fields of parent and child tables. Then return a list of objects representing this class to bind to.

I'm considering an ADO.NET approach for my particular situation - making use of a DataSet and the DataRelation class. Basically, we populate a single DataSet with the related tables and use the DataRelation class as described here:

http://www.codeguru.com/csharp/.net/net%5Fdata/datagrid/article.php/c10947

Anthony :-)

IrishChieftain