如何添加两个包含相同字段的数据表 [英] How Can I Add Two Datatables Which Contain Same Fields

查看:84
本文介绍了如何添加两个包含相同字段的数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用gridview显示的数据表,我有一个包含一些记录的下拉列表。当我从下拉列表中选择项目然后在选择的基础上我得到一个数据表的数据表,我想将该数据表添加到已经显示在gridview中的第一个数据表,我想要显示新旧记录到再次相同的gridview。怎么可能任何身体帮助我?

i have one datatable which is displaying using gridview and i have one dropdown list which contain some records . when i select the item from dropdown list then on the basis of selection i get i data table with one datarow and i want to add that data table to first data table which is already shown into gridview and i want show old and new added records into same gridview again . how it could be possible any body help me ??

推荐答案

正如你所说的你正在获得数据线,你可以使用 DataTable.NewRow() [ ^ ]添加方法它到数据表。



-KR
As you said you're getting a datatrow, you can use the DataTable.NewRow()[^] method for adding it to the datatable.

-KR






根据我的理解你想要将2个DataTables结果返回到1个DataTable的帖子,对吧。?



如果你的要求是这样的,你可以合并两个DataTable的以下方式。



Hi,

As per my understand the post you want to return 2 DataTables result into 1 DataTable, right.?

If your requirement is like this, you can Merge both DataTable's in the below manner.

dt1=dt1.Merge(dt2);





希望这对你有帮助..



Hope this will helpful to you..


这篇关于如何添加两个包含相同字段的数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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