2个表的搜索结果绑定到Gridview [英] Search Results from 2 tables Bind to Gridview
本文介绍了2个表的搜索结果绑定到Gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个带有列c1,c2,c3的表T1和带有c4,c5,c6的T2.
而且我想使用两个表中的c2和c4从两个表中进行搜索,并且我想绑定到Gridview.
我想在Gridview中显示c1,c2,c4,c5.
谁能告诉我使用2个表绑定到Gridview的代码.
谢谢您,
Hi All,
I have a table T1 with columns c1,c2,c3 and T2 with c4,c5,c6.
And I want to search from two tables using c2 and c4 from both tables and I want to bind to Gridview.
And I want to display c1,c2,c4,c5 in Gridview.
Can any one tell me the code to bind to Gridview using 2 tables.
Thank you,
推荐答案
尝试加入
点击这里:
http://blog.sqlauthority.com/2009 /04/13/sql-server-introduction-to-joins-basic-of-joins/ [ http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html [
Try Join
Click Here:
http://blog.sqlauthority.com/2009/04/13/sql-server-introduction-to-joins-basic-of-joins/[^]
http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html[^]
您需要将两个表合并为一个,
如果您有两个名为dtOne和dtTwo的表,则代码如下:
you need to merge two table in one,
if you have two table named dtOne and dtTwo this is the code:
dtAll = dtOne.Copy();
dtAll.Merge(dtTwo,true);
谁能告诉我要绑定的代码使用2个表访问Gridview.
1.网格可以一次绑定到一个表.
2.您需要形成一个SQL查询,该查询从两个表中获取数据
3.使用外键C1合并两个表,并通过单个查询获得公共结果
4.将此查询结果用作网格的数据源.
现在,尝试!如果遇到任何问题,请发布特定问题.
Can any one tell me the code to bind to Gridview using 2 tables.
1. Grid can bind to one table at a time.
2. You need to form a SQL query that fetches the data from the two table
3. Use Foreign Key C1 to combine the two table and get a common result through a single query
4. Use this query result as a data source of your grid.
Now, Try! Post specific issue if you face any.
这篇关于2个表的搜索结果绑定到Gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文