2 gridview中的主表和子表 [英] Master table and child table in 2 gridview

查看:66
本文介绍了2 gridview中的主表和子表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,





有2个网格视图的表格。



一个 gridview 用于父级,另一个gridview用于所选主记录的交易。







如何链接表格,以便在从主网格视图中选择记录时,它将填充子网格视图只有所选主信息的交易详情。





假设表有以下详细信息 idno,姓名,年龄。



孩子具有以下 idno,name,transaction_date ,金额





你如何链接2个表来填充他们的网格视图



我已经构建了各种网格视图,并且它们都被填充了整个记录



每张桌子。



我需要现在做墨水。





请协助或任何参考都可以接受





谢谢





Dear all,


have a form with 2 gridviews.

one gridview is for the parent and the other gridview is for the transaction of the selected master record.



How do you link the tables such that on selection of a record from the master gridview it will populate the child gridview with details of only the transactions of the selected master details.


Assuming the master table has the following details idno, name , age.

and the child has the following idno, name , transaction_date, amount


How do you link the 2 tables to populate their repective gridviews

I have built the various gridviews and they are all being populated with the entire records in

each table.

I need to now do the ink.


Please assist or any reference will be acceptable


Thanks


.

推荐答案

见下页:

http://msdn.microsoft.com/ en-us / library / aa479344 [ ^ ]

http://msdn.microsoft.com/en-us /library/aa992038.aspx [ ^ ]
See below page:
http://msdn.microsoft.com/en-us/library/aa479344[^]
http://msdn.microsoft.com/en-us/library/aa992038.aspx[^]


不确定您使用的是Windows Forms还是ASP.net,但如果您使用的是Forms,则应使用类 BindingSource



结合蛋白gSource类 [ ^ ]



如果你有一个带有两个数据表的数据集dsExample,它们有一个父数据表和一个父数据表子关系名为MasterTable_ChildTable,您创建两个绑定源。

Not sure if you are using Windows Forms or ASP.net, but if you are using Forms you should use the class BindingSource.

BindingSource Class[^]

If you have a DataSet, dsExample, with two data tables, MasterTable and ChildTable, which have a parent child relation named MasterTable_ChildTable, you create two binding sources.
// You don't usually do these steps manually, but in the property grid
// for each BindingSource in Visual Studio.
// Then you will get a dropdown list for each property.
// This is just to show the principle.
BindingSource bsMaster = new BindingSource();
bsMaster.DataSource = dsExample;
bsMaster.DataMember = "MasterTable";

BindingSource bsChild = new BindingSource();
bsChild.DataSource = bsMaster;
bsChild.DataMember = "MasterTable_ChildTable";

dataGridMaster.DataSource = bsMaster;
dataGridChild.DataSource = bsChild;



现在,当您更改主网格中的行时,带有子数据的数据网格中的值应该会更改。



我希望这会对你有所帮助。


Now the values in your datagrid with child data should change when you change rows in the master grid.

I hope this will help you on the way.


这篇关于2 gridview中的主表和子表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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