将GridView连接到两个或多个表 [英] connecting a gridview to two or more table

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

问题描述

是否可以同时将gridview连接到两个或多个表?请给我一个解决方案.预先谢谢您

Is it possible to connect a gridview to two or more tables at the same time ? Please give me a solution. thank you in advance

推荐答案

This [^]discussion could help you.


如果您绑定到具有关系的表,则会向下钻取能力.那是你想要的吗?

如果要绑定到数据库,还可以绑定到视图,这允许您从多个表中收集数据.

要包含两个或多个表的数据,您需要定义如何将它们合并到一个列表中以及合并到相同的数据类型.这意味着您需要编写自己的数据绑定源(从IBindingList,BindingSource或类似的东西继承).一个警告,让DataGridView与自定义数据绑定源类一起正常工作有点痛苦.
If you bind to a table with relationships, you get drill-down capabilities. Is that what you want?

You can also bind to a view, if you''re binding to a database, which allows you to collect data from several tables.

To include data for two or more tables you need to define how they get merged into one list, and to the same data type. That means you need to write your own data binding source (inheriting from IBindingList, BindingSource or something similar). A word of warning, getting a DataGridView to behave properly with a custom data binding source class is a bit of a pain.


您不能将其连接到两个表,但是可以创建一个包含所需表的视图,然后将gridview连接到该表.根据您的ORM,您正在考虑为视图创建某种数据对象,无论是ADO.net数据集/数据表,实体模型,POCO模板还是其他.然后,您可以像普通表一样进行数据绑定.
You can''t connect it to two tables, but you could create a view consisting of as many tables as you wish, and connect your gridview to that. Depending on your ORM, you''re looking at creating some sort of data object for the view, be it an ADO.net DataSet/DataTable, Entity Model, POCO Template or whatever. Then you can just databind as with a normal table.


这篇关于将GridView连接到两个或多个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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