开发者

Binding a DataGridView to multiple Tables in DataViewManager or DataSet

开发者 https://www.devze.com 2022-12-13 12:31 出处:网络
I have created three data tables by pulling data from an sql database.DT1, DT2, DT3. I have added these three tables to a data set, myDS.

I have created three data tables by pulling data from an sql database. DT1, DT2, DT3. I have added these three tables to a data set, myDS. I have added relations between these three tables. I then dragged a DataGridView onto my form and I want to bind the three tables to the DataGridview. So I added my dataset DS to a dataview manager, myDVM. I bound myDVM to a bindingsource, bindingSource1, and made it the data source for the DataGridView. I am not sure how to bind the tables I want from myDVM / bindingSource1, to appear in the DataGridView.

i want to display 开发者_C百科the child tables related to the parent table using primary key in the same datagridview!!

thanks in advance!!!

help me plz!!!


If by "display the child tables" you mean display related data from child tables, you should SELECT your data into a single table using the appropriate joins. DataGridViews display their data in a single-table format - there is no "multiple table" concept in a DataGridView.

DataSet.Merge() can help you to merge DataRows from separate objects into one.

0

精彩评论

暂无评论...
验证码 换一张
取 消