protected void GiftCertificatesGrid_RowCommand(object sender, GridViewCommandEventArgs e) { int GiftCertificateId = AlwaysConvert.ToInt(e.CommandArgument); GiftCertificate gc = GiftCertificateDataSource.Load(GiftCertificateId); if (gc == null) { return; } IGiftCertKeyProvider provider = AbleContext.Container.Resolve <IGiftCertKeyProvider>(); if (e.CommandName.Equals("Generate")) { gc.SerialNumber = provider.GenerateGiftCertificateKey(); gc.AddActivatedTransaction(); gc.Save(); GiftCertificatesGrid.DataBind(); } else if (e.CommandName.Equals("Deactivate")) { gc.SerialNumber = ""; gc.AddDeactivatedTransaction(); gc.Save(); GiftCertificatesGrid.DataBind(); } }
protected void Page_PreRender(object sender, EventArgs e) { if (this.Order != null) { IList <GiftCertificate> giftCertificateCollection = GetGiftCertificates(this.Order); if (giftCertificateCollection.Count > 0) { GiftCertificatesPanel.Visible = true; GiftCertificatesGrid.DataSource = giftCertificateCollection; GiftCertificatesGrid.DataBind(); } } }
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(); }
protected void BindGiftCertificatesGrid() { GiftCertificatesGrid.DataSource = GetGiftCertificates(); GiftCertificatesGrid.DataBind(); }