如何在将新行插入数据表时添加计数器值 [英] how to add counter value while inserting new row into datatable

查看:89
本文介绍了如何在将新行插入数据表时添加计数器值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DataTable DTRows;

int x = 0;

DTRows.Rows.Add(x);



这里x是反...它的值应该在DTRows中添加新行后增加

DataTable DTRows;
int x=0;
DTRows.Rows.Add(x);

here x is counter... its value should increament after adding new row into DTRows

推荐答案

请点击此链接:创建自动增量列 [ ^ ]
Follow this link: Creating AutoIncrement Columns[^]


尝试:

Try:
DataTable DTRows = new DataTable();
int x=0;
DTRows.Rows.Add(x++);

DataRowCollection的Add方法添加一个对象,而不是多行。

The Add method of a DataRowCollection adds an object, not a number of rows.


这篇关于如何在将新行插入数据表时添加计数器值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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