Ejemplo n.º 1
0
    /// <summary>
    /// 删除方法
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        CheckBox   chckbx      = null;
        LinkButton lkbtnDelete = null;
        string     Id          = "";

        for (int i = 0; i < this.gvDavnote.Rows.Count; i++)
        {
            chckbx      = this.gvDavnote.Rows[i].FindControl("chSelect") as CheckBox;
            lkbtnDelete = this.gvDavnote.Rows[i].FindControl("lnkdel") as LinkButton;
            if (chckbx.Checked)
            {
                string Id1 = lkbtnDelete.CommandArgument.ToString();
                Id += Id1 + ",";
            }
        }

        if (Id != "")
        {
            try
            {
                Id = Id.Substring(0, Id.Length - 1);


                CarDavnoteManager.DeleteDavnote(Id);
                Bind();
            }
            catch
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除失败!');", true);
                return;
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请选择要删除的项!');", true);
        }
    }
Ejemplo n.º 2
0
    protected void gvDavnote_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "del")
        {
            string Id = e.CommandArgument.ToString();
            try
            {
                int num = CarDavnoteManager.DeleteDavnote(Id);

                if (num > 0)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除成功!');", true);
                }
                Bind();
            }

            catch
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除失败!');", true);
                return;
            }
        }
    }