如何在一个下拉列表中填充不相关的两个数据表 [英] How to populate unrelated two data tables in one dropdowlist

查看:76
本文介绍了如何在一个下拉列表中填充不相关的两个数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在一个下拉列表中填充不相关的两个数据表?

How to populate unrelated two data tables in one dropdowlist?

推荐答案

使用联合
Select <column name=""> as ''DisplayText'',<column name=""> as '' ValueText'' from Table2

Union

Select <column name=""> as ''DisplayText'',<column name=""> as '' ValueText'' from Table2


将其作为数据源附加到下拉列表中.


Attach this as datasource to Drop down.


您可以从列表中的两个表中添加数据.

步骤1:

从两个SQL表中获取数据.


步骤2:

将表1中的数据添加到表1中,然后将表2中的数据添加到每个循环中或使用linq

步骤3:

将此列表传递给View层
You can add data from both the tables in list.

Step 1:

get Data from both the SQL tables.


step 2:

Add data in a list from table 1 and then table 2 using for each loop or using linq

step 3:

Pass this list to View layer


制作一个手动数据集,
使用for循环在数据集中添加两个dadatables的数据.
然后设置dropdowlist的属性,例如DataSource,DisplayMember和ValueMember
等等.您将在组合框中获得两个数据表的内容.
Make one manual Dataset,
add data of two dadatables in dataset using for loop.
Then set dropdowlist''s properties like DataSource,DisplayMember and ValueMember
etc.You will get contents of both datatables in combobox.


这篇关于如何在一个下拉列表中填充不相关的两个数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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