如何将单列中的两列值显示到gridview中。 [英] How to display two columns values into the single column into the gridview .
本文介绍了如何将单列中的两列值显示到gridview中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨专家,
我有两张桌子:
1。 Release_Master表:
Hi Experts,
I have two tables:
1. Release_Master Table:
col1 col2 col3.
A B C
D E F
2。 Knowissues_master表:
2. Knowissues_master Table:
col5 col6 col7 col8.
124 87 44 66
33 gh dd 44
我想在Gridview的单列中显示 col3
的Release_Master值和 col8
Knowissues_master的值
这样的事情:
I want to display col3
values of Release_Master and col8
values of Knowissues_master into the single column in the gridview
something like this:
Combined_column
C
F
66
44
如何通过代码(C#)实现此目的,或者我如何从选择中的sql server执行此操作声明。
请帮我解决这个问题。我将非常感谢。
How can I achieve this from code behind (C#) or how can I do this from sql server in the select statement.
Please help me out with this issue..i will appreciate you.
推荐答案
Hi ,
I have solved that issue myself by using the table variables in the sql server.
The following code will give the same result what I expected.
DECLARE @table1 TABLE (id int, name varchar(10))
INSERT INTO @table1 VALUES (1, 'issue1')
INSERT INTO @table1 VALUES (2,'issue2')
DECLARE @table2 TABLE (id int, name varchar(10), name2 varchar(10))
INSERT INTO @table2 VALUES (1, 'issue3','OneT')
INSERT INTO @table2 VALUES (2,'issue4','TwoT')
DECLARE @table3 TABLE (result nvarchar(max))
INSERT INTO @table3
SELECT name from @table1
UNION SELECT name from @table2
SELECT * FROM @table3
假设数据源有这两个字段,你可以使用模板字段
链接 [ ^ ]
如果是是不是你想要的:
你是说你有2个数据源,你希望从中做同样的事情?发布一些代码,它会更加清晰。
PS:对不起,如果这没有帮助
Assuming the data source has both the fields, you can use template fields
link[^]
If this is not what you are looking for:
Are you saying you have 2 data sources from which you wish to do the same? Post some code, it will be much more clearer.
PS: Sorry if this does not help
这篇关于如何将单列中的两列值显示到gridview中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文