在没有数据库的asp.net中使用数据集在datatable中插入多条记录? [英] Insert multiple record in datatable using dataset in asp.net without database?

查看:75
本文介绍了在没有数据库的asp.net中使用数据集在datatable中插入多条记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有些问题。我有三个文本框,有三个字段,一个按钮和一个gridview控件。我希望每当我点击添加按钮时,无需数据库即可在gridview中插入行和显示数据。但是当我点击添加按钮然后在gridview中添加一行记录,之后再次单击添加按钮,然后替换此行中的数据,而不是在gridview控件中插入第二行。所以,请帮助并建议我。





提前,很多人谢谢,

Hi All,

I have some problem. I have three textbox with three field, one button and one gridview control. I wants whenever i click on "ADD" button whichever insert row and display data in gridview without database. But when i click on "ADD" button then add one row record in gridview and after that click again "ADD" button then replaceed data in this row not insert the second row in gridview control. So please help and suggest me.


In Advance, Many Many Thanks,

推荐答案

您不需要数据库来拥有DataTable并将GridView绑定到它。您只需要DataTable对象,您可以根据需要添加所有行。但是,首先,您必须定义DataTable。你需要为它添加列,告诉它它们将要保存的数据类型,如果有主键,...等等,等等,等等......



构建完成后,可以在DataTable对象上调用NewRow方法以获取使用表格架构的DataRow,并使用用户输入的数据填充其中的字段,然后将行添加到DataRow.Rows集合。
You don''t need a database to have a DataTable and bind a GridView to it. You just need the DataTable object, to which you can add rows all you want. But, first, you have to define the DataTable. You need to add the columns to it, tell it what type of data they are going to hold, if there''s a primary key, ... blah, blah, blah, ...

Once you have that built, you can call the NewRow method on the DataTable object to get a DataRow that''s using the schema of the table, populate the fields in it with the data that the user entered, then add the row to the DataRow.Rows collection.


你谷歌了吗?



请看看这里: http ://geekswithblogs.net/dotNETvinz/archive/2008/05/07/adding-multiple-columns-and-rows-in-gridview-without-using-a-again.aspx [ ^ ]


这篇关于在没有数据库的asp.net中使用数据集在datatable中插入多条记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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