protected void lbDeleteSelected_Click(object sender, EventArgs e) { GridView activeGridView = mvGridViews.GetActiveView() == vwGridViewsNotFound ? gvNotFound : gvUrlTracker; foreach (GridViewRow row in activeGridView.Rows.OfType <GridViewRow>().Where(x => x.RowType == DataControlRowType.DataRow)) { CheckBox cbSelect = (CheckBox)row.FindControl("cbSelect"); if (cbSelect.Checked) { HiddenField hfId = row.FindControl("hfId") as HiddenField; if (hfId != null) { UrlTrackerRepository.DeleteUrlTrackerEntry(int.Parse(hfId.Value)); } else { HiddenField hfOldUrl = row.FindControl("hfOldUrl") as HiddenField; if (hfOldUrl != null) { UrlTrackerRepository.DeleteNotFoundEntriesByOldUrl(hfOldUrl.Value); } } } } activeGridView.DataBind(); if (activeGridView == gvNotFound && !UrlTrackerRepository.HasNotFoundEntries()) { lbUrlTrackerView_Click(this, EventArgs.Empty); mvSwitchButtons.Visible = false; } }
protected void lbDeleteErrorRows_Click(object sender, EventArgs e) { List <int> invalidRowIds; if (UrlTrackerRepository.HasInvalidEntries(out invalidRowIds)) { invalidRowIds.ForEach(x => { UrlTrackerRepository.DeleteUrlTrackerEntry(x); }); } Response.Redirect(Request.RawUrl); }