如何在数据集中的确切位置动态添加行 [英] How can i add the row dynamically at an exact postion in a dataset

查看:68
本文介绍了如何在数据集中的确切位置动态添加行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了代码以向数据集中添加动态列和行,但是该字段被添加到数据集中的某些位置,因此任何人都可以告诉我如何解决此问题
我的代码

I write a code to add dynamical column and row to a data set but the field is added some where in my data-set so can any one tell how can i resolve this
My code

for (int i = 0; i < Amount.Count; i++)
    {
        DataColumn dc = new DataColumn("Amount");
        local_ds.Tables[0].Columns.Add(dc);
        local_ds.Tables[0].Rows.Add(Amount[i]);
    }



但是该字段添加在下一行中,谁能说出如何实现此



But the field is adding in the next row can any one tell how to achieve this

推荐答案

尝试此

Try this

<pre>DataColumn dc = new DataColumn("Amount");<br />
local_ds.Tables[0].Columns.Add(dc);<br />
<br />
for (int i = 0; i < Amount.Count; i++)<br />
{<br />
    local_ds.Tables[0].Rows[i]["Amount"] = Amount[i];<br />
}</pre>


这篇关于如何在数据集中的确切位置动态添加行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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