void grdLister_RowsChanging(object sender, GridViewCollectionChangingEventArgs e) { if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove) { objMaster = new SubCompanyBO(); try { objMaster.GetByPrimaryKey((e.NewItems[0] as GridViewRowInfo).Cells["Id"].Value.ToInt()); objMaster.Delete(objMaster.Current); } catch (Exception ex) { if (objMaster.Errors.Count > 0) { ENUtils.ShowMessage(objMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } e.Cancel = true; } } }
void grdLister_CommandCellClick(object sender, EventArgs e) { try { GridCommandCellElement gridCell = (GridCommandCellElement)sender; RadGridView grid = gridCell.GridControl; if (gridCell.ColumnInfo.Name == "btnDelete") { if (DialogResult.Yes == RadMessageBox.Show("Are you sure you want to delete a Sub Company ? ", "", MessageBoxButtons.YesNo, RadMessageIcon.Question)) { gridCell.RowInfo.Delete(); } } else if (gridCell.ColumnInfo.Name == "ColEdit" && grdLister.CurrentRow != null && grdLister.CurrentRow is GridViewDataRowInfo) { objMaster.GetByPrimaryKey(grdLister.CurrentRow.Cells["Id"].Value.ToInt()); DisplayRecord(); } } catch (Exception ex) { //ENUtils.ShowMessage(ex.Message); } }