就是在我的程序里,想在删除时加一句JavaScript代码,有一个确定和取消,点确定就可以删除这条数据,所以我在
GridView1_RowDeleting 里面加上这句。。可是怎么样才能得到它返回的是确定还是取消呢?
protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
    {
        if (e.Exception == null)
        {
            MyTools.Msg("删除成功!", this, "Show.aspx");
        }
        else
        {
            MyTools.Msg("删除失败!", this);
            e.ExceptionHandled = true;
        }
    }
    
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
        Label lbl = (Label)row.FindControl("Label1");
        string row = lbl.Text;
    }

解决方案 »

  1.   

    就是在GridView1_RowDeleting里面再加一句Response.Write("<Script Language='JavaScript'>if ( window.confirm('确定要删除吗?')) {  window.location.href='" + strUrl_Yes +
                                  "' } else {window.location.href='" + strUrl_No + "' };</script>");
    怎么样得到它的返回值哦?
      

  2.   

     protected void  GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ((LinkButton)e.Row.Cells[删除按钮所在的列号].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('确认要删除吗?')");
            }
        }
      

  3.   

    if ( window.confirm('确定要删除吗?')) 
    {
      //用户点击的是确定
    }
    else
    {
      //用户点击的是取消
    }