GridView 编辑列的小问题

rooney321 rooney321 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
GridView1_RowUpdating 中
使用GridView1.Rows[e.RowIndex].Cells[0].Text; 为什么得到的值是原始值 而不是填入的新值???


代码如下:

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string a = this.GridView1.Rows[e.RowIndex].Cells[0].Text;
string b = this.GridView1.Rows[e.RowIndex].Cells[1].Text;
string c = this.GridView1.Rows[e.RowIndex].Cells[2].Text;
string d = this.GridView1.Rows[e.RowIndex].Cells[3].Text;
string e = this.GridView1.Rows[e.RowIndex].Cells[4].Text;
string constring;

string sql = "UPDATE XXX SET a='" + a + "', b='" + b + "', c='" + c + "', aprice='" + aprice + "' WHERE (servername='" + servername + "')";
constring = ConfigurationSettings.AppSettings["kkk"];
OleDbConnection scon = new OleDbConnection(constring);
OleDbCommand scmd = new OleDbCommand(sql, scon);
scon.Open();
scmd.ExecuteNonQuery();
this.GridView1.EditIndex = -1;
bindview(ViewState["sql"].ToString());

}
...全文
评论 9
收藏 已收藏
分享
返回顶部
rooney321
.NET社区 62,274 成员 668,968 内容