protected void gvResult_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandSource is Button) { bool blnSubjSave = false; Button l_lnkbtn_del = e.CommandSource as Button; if (l_lnkbtn_del.Text.ToLower() == "inactive") { if (e.Item.Cells[0].Text == "True") { CustomValidator lcv = ((CustomValidator)e.Item.Cells[7].FindControl("CustValDisable")); lcv.IsValid = false; } else { blnSubjSave = PE_DAL.DeleteSubject((int)gvResult.DataKeys[e.Item.ItemIndex]); this.gvResult.EditItemIndex = -1; Session.Remove("SubjectEditItemIndex"); } } else if (l_lnkbtn_del.Text.ToLower() == "active") { blnSubjSave = PE_DAL.EnableSubject((int)gvResult.DataKeys[e.Item.ItemIndex]); this.gvResult.EditItemIndex = -1; Session.Remove("SubjectEditItemIndex"); } if (blnSubjSave) { this.BindData(); } } }