/// <summary> /// Handles the Delete click event for the grid. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs" /> instance containing the event data.</param> protected void DeleteBlock_Click( object sender, Rock.Web.UI.Controls.RowEventArgs e ) { var rockContext = new RockContext(); BlockService blockService = new BlockService( rockContext ); Block block = blockService.Get( e.RowKeyId ); if ( block != null ) { string errorMessage; if ( !blockService.CanDelete( block, out errorMessage ) ) { mdGridWarning.Show( errorMessage, ModalAlertType.Information ); return; } blockService.Delete( block ); rockContext.SaveChanges(); BlockCache.Flush( e.RowKeyId ); } BindLayoutBlocksGrid(); }