日期:2014-05-17  浏览次数:20555 次

如何在删除数据前提示是否删除? 删除完了再返回页面怎么弄
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  {
  string id = e.CommandArgument.ToString();
   
   
  if (e.CommandName=="del")
  {
  string sc = "delete from t_users where user_id=" + id + "";

  DbHelper db = new DbHelper();
  DbCommand cmd = db.GetSqlStringCommond(sc);
   
  if (db.ExecuteNonQuery(cmd) != 0)
  {
   
  Response.Write("<script>alert('删除成功')</script>");
  return;
  }
  }
  }
这是我的删除代码

------解决方案--------------------
Response.Write("<script>alert('删除成功');window.location='" + Request.RawUrl + "'</script>");
------解决方案--------------------
在前台加
<asp:TemplateField HeaderText="删除" ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="lb_delete" runat="server" CausesValidation="False" CommandName="Delete"
Text="删除" OnClientClick='return confirm("此删除操作不可恢复,您确认删除此栏目吗?")'></asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>