将DataGridView绑定到DataViewManager或DataSet中的多个表 [英] Binding a DataGridView to multiple Tables in DataViewManager or DataSet

查看:366
本文介绍了将DataGridView绑定到DataViewManager或DataSet中的多个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过从sql数据库中提取数据创建了三个数据表。 DT1,DT2,DT3。
我已经将这三个表添加到数据集myDS。
我已经添加了这三个表之间的关系。
然后我将一个DataGridView拖到我的表单上,我想将三个表绑定到DataGridview。所以我把数据集DS添加到dataview管理器myDVM中。我将myDVM绑定到绑定源bindingSource1,并将其作为DataGridView的数据源。
我不知道如何绑定我想要从myDVM / bindingSource1的表,出现在DataGridView中。

i想显示与父表相关的子表,使用主键在同一个datagridview !!



提前谢谢



帮助我plz !!!

解决方案

如果通过显示子表表示从子表中显示相关数据,则应使用适当的连接将数据选择到单个表中。 DataGridViews以单表格式显示数据 - DataGridView中没有多表概念。



DataSet.Merge()可以帮助您将DataRows从单独的对象合并成一个。 >

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!!!

解决方案

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.

这篇关于将DataGridView绑定到DataViewManager或DataSet中的多个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆