protected void DeleteGiftCertificate(int GiftCertificateId) { GiftCertificate gc = null; foreach (OrderItem orderItem in _Order.Items) { gc = FindGiftCertificate(orderItem, GiftCertificateId); if (gc != null) { orderItem.GiftCertificates.Remove(gc); gc.Delete(); return; } } }
protected void MultipleRowDelete_Click(object sender, EventArgs e) { // Looping through all the rows in the GridView foreach (GridViewRow row in GiftCertificatesGrid.Rows) { CheckBox checkbox = (CheckBox)row.FindControl("DeleteCheckbox"); if ((checkbox != null) && (checkbox.Checked)) { // Retreive the GiftCertificateId int giftCertificateId = Convert.ToInt32(GiftCertificatesGrid.DataKeys[row.RowIndex].Value); GiftCertificate gc = GiftCertificateDataSource.Load(giftCertificateId); if (gc != null) { gc.Delete(); } } } GiftCertificatesGrid.DataBind(); }