protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
首先确定修改的数据类型跟数据库表的的数据类型统一,不统一要做个转换,不然出错
string upstr = "update 数据库 set 字段1="",字段2="","/"//更新字符串
conn.Open();
SqlCommand upcd = new SqlCommand(upstr,conn);
upcd.ExecuteNonQuery();
upcd.Dispose();
conn.Close();
//Reset the edit index.
GridView1.EditIndex = -1;
//Bind data to the GridView control.
BindData();//重新 绑定数据到GridView1
}
对你的dataset调用 getchanges函数,取出所有变更的数据。
在调用dataadapter的update方法,就可以快速的把所有变更写入数据库了。
好的!
已发请查收,这个是项目中的一部分
需要自己创建一个项目,把我的窗体添加进去。
丢进for循环这张表里面去呀