//判断为删除还是修改操作 protected void gvCustomers_RowCommand(object sender, GridViewCommandEventArgs e) { //删除 if (e.CommandName == "nDe") { bool res = Customer.DelCustomer(Convert.ToInt32(e.CommandArgument)); if (!res) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('该客户的相关信息正在使用中,不允许删除!')</script>"); } } //修改 else if (e.CommandName == "Ed") { //获取ID号 int Cusid = Convert.ToInt32(e.CommandArgument); //将ID号传到修改页面 Response.Redirect("~/Customers/UpdateOrEditCustomer.aspx?Cusid=" + Cusid); } //更新数据 allCustomers = Customer.GetAllCustomers(); anpPage.RecordCount = allCustomers.Count; //显示信息 DisplayCustomer(); }