void Grid_RowsChanging(object sender, GridViewCollectionChangingEventArgs e) { if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove) { objMaster = new BookingBO(); try { objMaster.GetByPrimaryKey(grdLister.CurrentRow.Cells["Id"].Value.ToInt()); if (objMaster.Current != null) { objMaster.Delete(objMaster.Current); } } catch (Exception ex) { if (objMaster.Errors.Count > 0) { ENUtils.ShowMessage(objMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } e.Cancel = true; } } }
private void btnDeleteSelected_Click(object sender, EventArgs e) { try { if (grdLister.Rows.Where(c => c.Cells["Check"].Value.ToBool()).Count() == 0) { return; } if (DialogResult.Yes == RadMessageBox.Show("Are you sure you want to delete Selected Booking(s) ? ", "", MessageBoxButtons.YesNo, RadMessageIcon.Question)) { foreach (GridViewRowInfo row in grdLister.Rows.Where(c => c.Cells["Check"].Value.ToBool())) { objMaster = new BookingBO(); objMaster.GetByPrimaryKey(row.Cells["Id"].Value.ToInt()); if (objMaster.Current != null) { objMaster.Delete(objMaster.Current); } } PopulateData(); } } catch (Exception ex) { if (objMaster.Errors.Count > 0) { ENUtils.ShowMessage(objMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } } }