/// <summary> /// Handles the Delete event of the gLinkList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param> protected void gLinkList_Delete(object sender, RowEventArgs e) { var rockContext = new RockContext(); var personalLinkService = new PersonalLinkService(rockContext); var personalLink = personalLinkService.Get(e.RowKeyId); if (personalLink != null) { string errorMessage; if (!personalLink.IsAuthorized(Authorization.EDIT, CurrentPerson)) { mdGridWarning.Show("You are not authorized to delete this link", ModalAlertType.Information); return; } if (!personalLinkService.CanDelete(personalLink, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } personalLinkService.Delete(personalLink); rockContext.SaveChanges(); } BindGrid(); }