如何在组合框的下拉列表中显示两列? [英] How to display two columns in dropdownlist of combo box ?

查看:124
本文介绍了如何在组合框的下拉列表中显示两列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

2.Columns UOM1和UOM2



2.Columns UOM1 and UOM2

UOM1        UOM2
---         ---
PIECES      BOX







我想在组合框中显示的是



PIECES

BOX





我怎么写才能得到它。



OP的附加内容从非解决方案下移

感谢您的回复(解决方案1 ​​by _TR _)



3Columns Produtct_Id,UOM1和UOM2在表格中






what I want to display in combobox is

PIECES
BOX


How could I write to get that fromat.

OP''s additional content moved from non-solution below
thanks for your reply (solution 1 by _TR_)

3Columns Produtct_Id, UOM1 and UOM2 in a table

Product_Id     UOM1       UOM2
-----------     ---        ---
   1.          PIECES      BOX
   2.          BOTTLE      CTN
   3.          PACKET      BAN







我想在combobox中显示的内容基于product_id,当我从Combobox中选择Product_Id 1时,想要在另一个组合框中绑定UOM1和UOM2值。不是所有的数据。



例如:select Product_Id 1.



只显示组合框上的这两个数据。 />


PIECES

BOX



我应该如何重写sql语句?

虽然我尝试使用该语句,但显示所有数据。






what I want to display in combobox is based on the product_id, while I choose Product_Id 1 from a Combobox, want to bind UOM1 and UOM2 value in the another combobox. Not all the data.

for example: select Product_Id 1.

just only display those two data on combobox.

PIECES
BOX

How should I rewrite the sql statement?
Although I try to use that statement, show all the data in.

create procedure GetTwoProduct
(
    @id int
)
as

SELECT UOM1_Code AS UOM FROM Product
UNION ALL
SELECT UOM2_Code AS UOM FROM Product
where Product.Product_Id = @id

推荐答案

假设你正在从数据库中检索数据,你可以尝试

Assuming you are retrieving data from database, you can try
SELECT UOM1 AS UOM FROM [YourTable]
UNION ALL
SELECT UOM2 AS UOM FROM [YourTable]





列UOM1和UOM2应具有相同的数据类型。



如果您有任何疑问,请告诉我。



The columns UOM1 and UOM2 should be of same data type.

Let me know if you have any doubts.


这篇关于如何在组合框的下拉列表中显示两列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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