Binding a DataGridView to multiple Tables in DataViewManager or DataSet

陌路散爱 提交于 2019-12-12 02:58:51

问题


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 the child tables related to the parent table using primary key in the same datagridview!!

thanks in advance!!!

help me plz!!!


回答1:


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.



来源:https://stackoverflow.com/questions/1830761/binding-a-datagridview-to-multiple-tables-in-dataviewmanager-or-dataset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!