C#DataList修改更新操作
C#DataList中实现修改的操作,点击编辑按钮,文本框可进行编辑,点击更新获取文本框最新内容更新数据库,但为什么获取到的文本框数据还是编辑之前的空,有什么办法解决pr...
C#DataList中实现修改的操作,点击编辑按钮,文本框可进行编辑,点击更新获取文本框最新内容更新数据库,但为什么获取到的文本框数据还是编辑之前的空,有什么办法解决 protected void dtlist_EditCommand(object source, DataListCommandEventArgs e) { TextBox t = e.Item.FindControl("TextBox3") as TextBox; t.ReadOnly = false; } protected void dtlist_UpdateCommand(object source, DataListCommandEventArgs e) { Label l = e.Item.FindControl("Label4") as Label; string loy = l.Text; TextBox t = e.Item.FindControl("TextBox3") as TextBox; string content = t.Text; t.ReadOnly = true; if (e.CommandName == "Update") { string SQL = @"update YiHui_MenuInfo set IconLink=" + "'" + content + "'" + " where Layout=" + loy; SqlConnection con = new SqlConnection(sconnstring); con.Open(); SqlCommand com = new SqlCommand(SQL, con); int i = com.ExecuteNonQuery(); con.Close(); if (i > 0) { Response.Write("<script type='text/javascript'>alert('修改成功')</script>"); page = Convert.ToInt32(ViewState["page"]); count = int.Parse(TextBox1.Text); starNum = (page - 1) * count + 1; endNum = page * count; dtlist.DataSource = GetDT(starNum, endNum); dtlist.DataBind(); } else { Response.Write("<script type='text/javascript'>alert('修改失败')</script>"); page = Convert.ToInt32(ViewState["page"]); count = int.Parse(TextBox1.Text); starNum = (page - 1) * count + 1; endNum = page * count; dtlist.DataSource = GetDT(starNum, endNum); dtlist.DataBind(); } } }
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询