修改添加到数据集中的行 [英] Modify rows added into dataset
本文介绍了修改添加到数据集中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何可能?
此外,数据集2行必须根据dataset1列。说如果第1列是'Y',那么应该添加数据集2行。
解决方案
C#版本(请接受f0x的答案,如果这是您要查找的方法):
UPDATED以解决上述错误 - 使用ImportRow / p>
if(dataset1.Tables [0] .Rows [0] [0] .ToString()==Y)
{
for(int i = 0; i< dataset2.Tables [0] .Rows.Count - 1; i ++)
{
dataset1.Tables [0] .ImportRow (dataset2.Tables [0] .Rows [i]);
}
}
I have a dataaset1 which contains 17-20 rows. Now i have another dataset as dataset2, containing 4-5 rows. the rows of dataset 2 should be added into dataset1, which then should be binded to grid again (containing 22-25 rows in total).
How is that possible?
Also, the dataset 2 rows have to be added based on some condition of dataset1 column. Say if column 1 is 'Y', then the dataset 2 rows should be added.
解决方案
C# Version (Please accept f0x's answer if this is the method you're looking for):
UPDATED to address error above - use ImportRow
if (dataset1.Tables[0].Rows[0][0].ToString() == "Y")
{
for (int i = 0; i < dataset2.Tables[0].Rows.Count - 1; i++)
{
dataset1.Tables[0].ImportRow(dataset2.Tables[0].Rows[i]);
}
}
这篇关于修改添加到数据集中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文