MUI获取文本框的值

展开阅读全文

获取文本框中的值

01-04

问题如下:rn在页面的后台load事件中给文本框赋值了rn然后我要对文本框中的值进行修改再保存,可是修改之后不能获取修改后文本框中的内容,程序调试的时候发现 保存的程序中还是load事件赋的值 没有变化rn string no = "";rn protected void Page_Load(object sender, EventArgs e)rn rn DbHelper db = new DbHelper();rn DbCommand cmd = db.GetSqlStringCommond("select top 1 * from companyinfo");rn DbDataReader reader = db.ExecuteReader(cmd);rn if (reader.Read())rn rn cmpaddress.Text = reader["address"].ToString().Trim();rn cmpcode.Text = reader["code"].ToString().Trim();rn cmpcontactpeople.Text = reader["contactpeople"].ToString().Trim();rn cmpemail.Text = reader["email"].ToString().Trim();rn cmpfax.Text = reader["fax"].ToString().Trim();rn cmpname.Text = reader["companyname"].ToString().Trim();rn cmpphone.Text = reader["phone"].ToString().Trim();rn cmpqyln.Text = reader["qiyelinian"].ToString().Trim().Replace("$", "\r\n");rn cmptel.Text = reader["tel"].ToString();rn cmpjianjie.Text = reader["jianjie"].ToString().Replace("$", "\r\n");rn no = reader["infoid"].ToString().Trim();rn rn elsern rn MessageBox.Show(this, "用户名不存在!");rn rn rn protected void btnAdd_Click(object sender, EventArgs e)rn rn tryrn rn DbHelper db = new DbHelper();rn DbCommand cmd = db.GetSqlStringCommond("update companyinfo set companyname=@cmpname,contactpeople=@cmpcontactpeople ,tel=@cmptel,"+rn "phone=@cmpphone ,fax=@cmpfax,address=@cmpaddress,email=@cmpemail,code=@cmpcode,"+rn "qiyelinian=@cmpqiyelinian,imgname=@cmpimgname,jianjie=@cmpjianjie" +rn " where infoid=@id");rn db.AddInParameter(cmd, "@cmpname", DbType.String, cmpname.Text.Trim());rn db.AddInParameter(cmd, "@cmpcontactpeople", DbType.String, cmpcontactpeople.Text.Trim());rn db.AddInParameter(cmd, "@cmptel", DbType.String, cmptel.Text.Trim());rn db.AddInParameter(cmd, "@cmpphone", DbType.String, cmpphone.Text.Trim());rn db.AddInParameter(cmd, "@cmpfax", DbType.String, cmpfax.Text.Trim());rn db.AddInParameter(cmd, "@cmpaddress", DbType.String, cmpaddress.Text.Trim());rn db.AddInParameter(cmd, "@cmpemail", DbType.String, cmpemail.Text.Trim());rn db.AddInParameter(cmd, "@cmpcode", DbType.String, cmpcode.Text.Trim());rn db.AddInParameter(cmd, "@cmpimgname", DbType.String, imgupload.FileName);rnrn string qiyelinian = this.cmpqyln.Text.Trim().Replace("\r\n", "$");rn string content = this.cmpjianjie.Text.Trim().Replace("\r\n", "$");rnrn db.AddInParameter(cmd, "@cmpqiyelinian", DbType.String, qiyelinian);rn db.AddInParameter(cmd, "@cmpjianjie", DbType.String, content);rn db.AddInParameter(cmd, "@id", DbType.String, no);rnrn if (db.ExecuteNonQuery(cmd) == 1)rn rn MessageBox.Show(this, "成功修改");rn rn elsern rn MessageBox.Show(this, "修改失败,请重新修改!");rn rn rn catch (Exception ee)rn rn MessageBox.Show(this, ee.ToString());rn rn 论坛

没有更多推荐了,返回首页