现在页面上有一个TextBox和一个确定按钮,TextBox初始值是数据库茶来的一个值,想在TextBox内对其进行修改,修改后再保存到数据库,可是现在保存的却是原来的值,而不是修改后的。
代码如下:请各位高手指点迷津。
protected void Page_Load(object sender, EventArgs e)
{
id = Request.QueryString["Tcbh"];
yd = Request.QueryString["pyyd"];
Session["xid"] = id;
Session["xyd"] = yd;
string xid = (string)Session["xid"];
string xyd = (string)Session["xyd"];
db = new DBAccess();
sql1 = "select ydjh from ydpy where Tcbh='" + id + "' and pyyd='" + yd + "'";
DataSet dv1 = db.executeQuery(sql1);
if (dv1.Tables[0].Rows.Count > 0)
{
str1 = dv1.Tables[0].Rows[0]["ydjh"].ToString();
TextBox1.Text = str1;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
str2 = TextBox1.Text;
db = new DBAccess();
sql2 = "update ydpy set ydjh='" + str2 + "' where Tcbh='" + id + "' and pyyd='" + yd + "'";
Response.Write(sql2);
Response.End();
isok = db.executeUpdate(sql2);
if (isok == true)
{
TextBox1.Text = "";
Function.printJS(Response, "alert(\"修改成功!\");window.parent.close();");
}
}