如何在C#中将4个数据表合并为一个? [英] how to merge 4 datatables into one in c#?

查看:105
本文介绍了如何在C#中将4个数据表合并为一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个datagridview和四个datagridcomboboxcolumns.
我想将四个不同的列表绑定到四个datagridComboboxcolumns.

所以我用逻辑来解决这个问题:
1.将每个列表添加到每个数据表中.
2.将所有四个数据表合并为一个数据表.
3.将最终数据表与datagridview绑定.

但是我在合并所有数据表时遇到问题
到一个数据表.如果我将第二张桌子添加到第一张桌子.然后第二张表
从第一个表的最后一个值的下一行开始.它不是从
添加 数据表的第一个索引.

那么有人可以给我上述问题的代码逻辑吗?
或绑定4个列表的任何更好的主意
到我的datagridview ???

任何人都可以通过dis指导我吗?

瑞格斯,
Mohana

Hi All,

I have one datagridview with four datagridcomboboxcolumns.
I want to bind four different lists to four datagridComboboxcolumns.

So i am approaching this with the logic:
1.Adding each list to each datatable.
2.Merging all four datatables to one datatable.
3.Binding final datatable with the datagridview.

But i am having problem in merging all datatable
to one datatable.? If i add second table to first one. Then secondtable column
starts from the next row of the last value of first table. It is not adding from the
first index of the datatable.

So Can anyone give me codelogic for above problem?
Or any better idea of binding that 4 lists
to my datagridview???

Whichever can anyone guide me with dis??

Regars,
Mohana

推荐答案


如果所有数据表的表架构都相同,则可以使用数据集,并使用各自的数据表调用数据集的合并功能.

祝一切顺利.
--AK
Hi,
If the schema of your table is same for all datatables then you can use a dataset and call the merge function of the dataset with respective datatable.

All the best.
--AK


我的建议尝试编写存储过程算出那个位置,使单个Temp Table成为一个临时表,然后将其作为数据表或数据集获取,以分配最好的方式和简单的gridview数据源.

注意:
1.最后让查询返回像有4个Dropdownlist Text和value字段一样的列

2.在绑定时间"下拉列表中为所有四个相同的数据源,但每个下拉列表针对同一数据源表列使用不同的文本和值字段
My Advise Try to Write A Store Procedure Work out that place make single Temp Table then fetch it that as datatable or dataset to assign gridview datasource thats best way and simple one

Note:
1.Finally make query return like have 4 Dropdownlist Text and value field as colum

2.In Bind time dropdown datasource for all 4 same but each dropdown different text and value field for that same Datasource table column


这篇关于如何在C#中将4个数据表合并为一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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