protected void GridView1_OnRowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow gRow = (GridViewRow)((Control)e.CommandSource).Parent.Parent; string userGroupID = GridView1.DataKeys[gRow.RowIndex].Value.ToString(); if (e.CommandName == "Edit") { Response.Redirect("UserGroupEdit.aspx?UserGroupID=" + userGroupID + " &Type=1"); } if (e.CommandName == "Del") { if (UserRoleMenu.IsCanDelUserGroup(userGroupID)) { if (UserManage.DeleteUserGroup(int.Parse(userGroupID))) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "DataSucess", "alert('删除成功!');", true); LoadData(1); } else { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "DataFail", "alert('删除失败!');", true); } } else { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "DataError", "alert('用户组已经分配用户,请先删除该用户组下的所有用户!');", true); } } }