添加列并在Asp.net C#中更新数据集的该列 [英] Add Column and Update that column of DataSet in Asp.net C#

查看:124
本文介绍了添加列并在Asp.net C#中更新数据集的该列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了数据集并可以正常工作.
现在我想添加一列并对其进行更新.
帮帮我.

I had created dataset and its properly working.
Now i want to add a column and update it.
Help me.

推荐答案

添加如下所示的列.
Add the column like below.
dataset.Tables[0].Columns.Add(new DataColumn ("columnname"));


更新列值,如下所示.


Update the columns values like below.

for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
  dataset.Tables[0].Rows[i]["columnname"] = "new value here";
}


步骤类似于:
-创建一个新的 DataColumn [ [ ^ ]集合
-创建 DataRow [NewRow [项目 [ [接受更改 [
The steps would be something like:
- create a new DataColumn[^]
- add it to the data table''s Columns[^] collection
- Create a DataRow [^] for example using NewRow[^]
- Modify the values of the row as per needed using Item[^] indexer
- add the row to Rows[^] collection
- after succesful modifications AcceptChanges[^]


这篇关于添加列并在Asp.net C#中更新数据集的该列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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