Click here to Skip to main content
15,908,675 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two tables with one to many relation. I need to populate the related id field with the contents of the related table. Can you let me know how can I achieve this.
Posted

You can achieve this by using nested grid views. The parent grid views will display all the master records. The nested grid view will display all the child records. The parent row should have datakeys associated with it so as to uniquely identify its child records.
 
Share this answer
 
Comments
J imran 8-Dec-11 5:55am    
Thank you for answering.
ok Can you let me know How can I go for nested grid views?
I believe you need to study SQL Joins. Here is a previous article regarding SQL Joins. Study it.

Visual Representation of SQL Joins[^]

Regards,
Eduard
 
Share this answer
 
first you need to join two tables based on the primary key and foreign key, use the same query to query from the database.
save the sample queried from database in datatable
and finally you need to to bind the datatable to the gridview
 
Share this answer
 
Comments
J imran 8-Dec-11 5:57am    
but if I do this the save option is gone. that is the main issue. can I join the tables such that I can save the grid view in corresponding data table.
Jephunneh Malazarte 8-Dec-11 11:30am    
J are you trying to display the information from 2 related tables in your gridview and then from the gridview you let the user modify the data "from the gridview" and then when the user click the save button the updates will automatically save to its corresponding tables?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900