void control_OnEditCardInfo(object sender, CardInfoDetailEventArgs e)
        {
            GatewayPaymentProfile profile = GatewayPaymentProfileDataSource.Load(e.ProfileId);

            if (profile != null)
            {
                HiddenProfileId.Value = profile.Id.ToString();
                NameOnCardLabel.Text  = string.Format("{0}", profile.NameOnCard);
                ReferenceLabel.Text   = string.Format("Profile {0} ending in {1}", profile.InstrumentType, profile.ReferenceNumber);

                string   profileExpiry = profile.Expiry.ToString();
                string[] dateParts     = profileExpiry.Split('/');
                string   expiryMonth   = (dateParts[0].Length == 1) ? "0" + dateParts[0] : dateParts[0];
                string   expiryDay     = dateParts[1];
                string   expiryYear    = dateParts[2].Substring(0, 4);

                ListItem selectedYear = ExpirationYear.Items.FindByValue(expiryYear);
                if (selectedYear != null)
                {
                    ExpirationYear.ClearSelection();
                    selectedYear.Selected = true;
                }

                ListItem selectedMonth = ExpirationMonth.Items.FindByValue(expiryMonth);
                if (selectedMonth != null)
                {
                    ExpirationMonth.ClearSelection();
                    selectedMonth.Selected = true;
                }

                EditCardInfoPopUp.Show();
            }
            else
            {
                HiddenProfileId.Value = string.Empty;
            }
        }
    public void BindPage(Int64 paymentProfileId)
    {
        DisableButtonOnClick(ButtonSave);

        ErrorMessage.Text     = string.Empty;
        TextCardSecurity.Text = string.Empty;
        TextCreditCard.Text   = string.Empty;

        AspDotNetStorefrontCore.Customer adnsfCustomer = AspDotNetStorefrontCore.Customer.Current;
        int customerId = adnsfCustomer.CustomerID;

        PanelError.Visible = false;
        PopulateExpirationDates();
        PopulateAddresses(customerId);

        this.PaymentProfileId = 0;         // initially zero

        if (paymentProfileId <= 0)
        {
            return;
        }

        Int64 profileId = DataUtility.GetProfileId(customerId);

        if (profileId <= 0)
        {
            return;
        }

        var profileMgr     = new ProfileManager(customerId, adnsfCustomer.EMail, profileId);
        var paymentProfile = profileMgr.GetPaymentProfile(paymentProfileId);

        if (paymentProfile == null)
        {
            return;
        }

        this.PaymentProfileId = paymentProfileId;

        var ccPayment          = (GatewayAuthorizeNet.AuthorizeNetApi.CreditCardMaskedType)paymentProfile.payment.Item;
        var dataPaymentProfile = DataUtility.GetPaymentProfile(adnsfCustomer.CustomerID, this.PaymentProfileId);

        TextCreditCard.Text   = ccPayment.cardNumber;
        TextCardSecurity.Text = string.Empty;

        ExpirationMonth.ClearSelection();
        var foundItem = ExpirationMonth.Items.FindByValue(dataPaymentProfile.ExpirationMonth);

        if (foundItem != null)
        {
            foundItem.Selected = true;
        }

        ExpirationYear.ClearSelection();
        foundItem = ExpirationYear.Items.FindByValue(dataPaymentProfile.ExpirationYear);
        if (foundItem != null)
        {
            foundItem.Selected = true;
        }

        var address = DataUtility.GetPaymentProfile(customerId, this.PaymentProfileId);

        if (address != null)
        {
            BillingAddresses.ClearSelection();
            BillingAddresses.Items.FindByValue(address.AddressId.ToString()).Selected = true;
        }
    }