将所有gridview数据插入表中 [英] Insert all gridview data into a table

查看:68
本文介绍了将所有gridview数据插入表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何一次性将gridview的所有数据插入到表中?

How to insert all the data of a gridview to a table in one shot?

推荐答案

使用不带xxxDataSource(SqlDataSource,ObjectDataSource等)的GridView进行批量编辑 [ ^ ]
一次将多行发送到存储过程中 [
Real World GridView: Bulk Editing[^]
Bulk Edit with GridView without xxxDataSource (SqlDataSource, ObjectDataSource, etc.)[^]
send multiple rows at once into a stored procedure[^]


请参阅类似的问题/答案:如何将所有数据从网格视图插入表中 [从gridview批量插入数据库 [使用GridView和Sql批量插入服务器 [ ^ ]

这是另一个关于CP的信息:使用GridView进行批量编辑而不使用xxxDataSource(SqlDataSource ,ObjectDataSource等) [ ^ ]
Please refer similar question/answer: how to insert all rows data from a gridview to a table[^]

Bulk insert from gridview to database[^]

Some nice articles on same:
Bulk Insert using GridView and Sql Server [^]

Here''s another on CP: Bulk Edit with GridView without xxxDataSource (SqlDataSource, ObjectDataSource, etc.)[^]


首先从gridview中选择第一行详细信息,然后使用for循环将带有附加信息的新行插入到新表中.

1st select the 1st row details from gridview den use for loop to insert the into new table with additional information.

for(int i=0;i<gridview1.rows.count;i++)>
{
string num = GridView1.Rows[i].Cells[1].Text;
string staff_dept = GridView1.Rows[i].Cells[2].Text;
string str = "insert into intrmarks(VTUNO,dept)values(''" + num + "'',''" + staff_dept + "'')";
SqlCommand strCmd = new SqlCommand(str, con);
strCmd.ExecuteNonQuery();
 
}


这篇关于将所有gridview数据插入表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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