Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datasets, Parent/Child table relations and Gridview controls

I have a parent table called Publication and a child table called Owner. These two (data)tables are contained within a DataSet (this is all C# stuff) and have a defined relationship. One publication can have more than one owner.

I am using a GridView control and my question is, how do I get the information in the child table to show up in the gridview control? The gridview is linked to the main dataset.

I have read the information here, but what's annoying is that writing stuff to the console isn't very useful!

http://msdn.microsoft.com/en-us/library/d6s958d6(VS.80).aspx

Thanks R.

like image 636
flavour404 Avatar asked Nov 26 '25 17:11

flavour404


1 Answers

Are you wanting the child information to overwirte what is in the parent grid, show up as nested rows under the parent row, or the easiest way, show another grid below that grid and then on selection of the parent grid row, populate the bottom grid with the subset information?

Take a look at http://www.asp.net/learn/data-access/tutorial-10-cs.aspx

Instead of sticking the info in the details view, just use another gridview. Clarify your desired output and I can perhaps point you in a better direction.

UPDATE: I believe this article which has detailed code will give you exactly what you are looking for, although there might be an easier way or a more elegant solution, this will at least get you up and running for now.

http://www.aspboy.com/Categories/GridArticles/Hierarchical_GridView_With_Clickable_Rows.aspx

like image 109
Breadtruck Avatar answered Nov 29 '25 06:11

Breadtruck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!