DATALIST编辑更新的问题
stringempid=this.DataList1.DataKeys[e.Item.ItemIndex].ToString();stringname=((TextBox...
string empid = this.DataList1.DataKeys[e.Item.ItemIndex].ToString();
string name = ((TextBox)e.Item.FindControl("t1")).Text;
string adress = ((TextBox)e.Item.FindControl("t2")).Text;
SqlConnection x = new SqlConnection("server=.;database=nu;uid=sa;pwd=50820419");
SqlCommand cmd = new SqlCommand("update biao set name='" + name + "',adress='" + adress + "'where id='" + empid + "'", x);
x.Open();
cmd.ExecuteNonQuery();
this.DataList1.EditItemIndex = -1;
this.DataList1.DataSource = Class2.db();
this.DataList1.DataKeyField = "id";
this.DataList1.DataBind();
为什么我输入更新字段后,点更新按钮后,选择的这项数据库内容变空了?
是没有取道值。要怎么修改才好啊?文本框里我输入后,更新无效 展开
string name = ((TextBox)e.Item.FindControl("t1")).Text;
string adress = ((TextBox)e.Item.FindControl("t2")).Text;
SqlConnection x = new SqlConnection("server=.;database=nu;uid=sa;pwd=50820419");
SqlCommand cmd = new SqlCommand("update biao set name='" + name + "',adress='" + adress + "'where id='" + empid + "'", x);
x.Open();
cmd.ExecuteNonQuery();
this.DataList1.EditItemIndex = -1;
this.DataList1.DataSource = Class2.db();
this.DataList1.DataKeyField = "id";
this.DataList1.DataBind();
为什么我输入更新字段后,点更新按钮后,选择的这项数据库内容变空了?
是没有取道值。要怎么修改才好啊?文本框里我输入后,更新无效 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询