protected void DelegationScheduleGridView_RowDeleting(object sender, GridViewDeleteEventArgs e) { int Id = Convert.ToInt32(DelegationScheduleGridView.DataKeys[e.RowIndex].Values[0]); GridViewRow row = DelegationScheduleGridView.Rows[e.RowIndex]; DateTime? start = SupplierBizLogic.findStartDate(Id); DateTime? end; if (start >= DateTime.Now.Date) { SupplierBizLogic.DeleteDelegation(Id); this.BindGrid(); } else { end = DateTime.Now.Date.AddDays(-1); SupplierBizLogic.UpdateDelegation(Id, end); } }