protected void lnkremove_Click(object sender, EventArgs e) { LinkButton lnk = sender as LinkButton; GridViewRow row = lnk.NamingContainer as GridViewRow; int id = int.Parse(grd_users.DataKeys[row.RowIndex].Value.ToString()); bus.id = id; int r = bus.deleteuser(); // now doing only soft delete if (r == 1) //success { fillusers(); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "success();", true); } else if (r == 2) //no lid { fillusers(); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "errornolid();", true); } else //fail { fillusers(); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "error();", true); } }