GridView 编辑列的小问题
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());
}
使用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());
}
...全文
相关推荐
GridView编辑删除总结[定义].pdf
GridView编辑删除总结[定义].pdf
gridview使用技巧、gridview使用大全、gridview常用问题、gridview常用方法
gridview使用技巧、gridview使用大全、gridview常用问题、gridview常用方法 共12文件 长期收集的 绝对有用
ASP.NET GridView 动态添加模板列示例
ASP.NET C# 编写的GridView和DropDownList的搭配,当然你也可以使用任意你需要的控件,例如 TextBox 和 .NET 的 Validator。
GridView中行的编辑与删除
ASP.NET中GridView控件对数据库数据的显示、编辑以及删除。编辑和删除使用控件自带功能。
显示隐藏GridView的列源码.zip
显示隐藏GridView的列源码.zip


