public void grdEstimateMaterials_DeleteCommand(object sender, DataGridCommandEventArgs e) { contingency _wc = new contingency(); String DetailId = ""; DetailId = grdEstimateMaterials.DataKeys[Convert.ToInt32(e.Item.ItemIndex)].ToString(); Whitfieldcore _dbClass = new Whitfieldcore(); _wc.DeleteContingency(Convert.ToInt32(DetailId)); _wc.DeleteSubContingencyForContingency(Convert.ToInt32(DetailId)); DataSet dsGridResults = _wc.FetchContingencyData(); PopulateDataGrid(dsGridResults, grdEstimateMaterials); }