/// <summary>
        /// Binds the shipments grid.
        /// </summary>
        private void BindShipmentsGrid()
        {
            object dataSource = GetShipmentsDataSource();

            if (dataSource != null)
            {
                ShipmentList.DataSource = dataSource;
                ShipmentList.DataBind();
            }
        }
        private void BindShipmentList(Order order)
        {
            List <OrderShipment> firstTwoShipments = new List <OrderShipment>();

            firstTwoShipments.Add(order.Shipments[0]);
            if (order.Shipments.Count > 1)
            {
                firstTwoShipments.Add(order.Shipments[1]);
            }
            ShipmentList.DataSource = firstTwoShipments;
            ShipmentList.DataBind();
            MoreShipmentsLink.Visible     = order.Shipments.Count > 2;
            MoreShipmentsLink.NavigateUrl = GetShipmentDetailsUrl(order);
        }
        protected void SubmitButton_Click(object sender, System.EventArgs e)
        {
            ShippingEstimatePopup.Show();
            if (Page.IsValid && PostalCodeIsValid())
            {
                // ENSURE THE BASKET IS PACKAGED
                IBasketService preCheckoutService = AbleContext.Resolve <IBasketService>();
                preCheckoutService.Package(_Basket);
                _ShipmentCount = _Basket.Shipments.Count;

                // BUILD THE ADDRESS OBJECT TO USE FOR THE RATE ESTIMATE
                _EstimateAddress             = new Address();
                _EstimateAddress.CountryCode = Country.SelectedValue;
                if (phProvinceField.Visible)
                {
                    _EstimateAddress.Province = Province.SelectedValue;
                }
                if (phCityField.Visible)
                {
                    _EstimateAddress.City = StringHelper.StripHtml(City.Text);
                }
                if (phPostalCodeField.Visible)
                {
                    string safePostalCode = StringHelper.StripHtml(PostalCode.Text);
                    safePostalCode              = Regex.Replace(safePostalCode.ToUpperInvariant(), "[^-A-Z0-9]", string.Empty);
                    PostalCode.Text             = safePostalCode;
                    _EstimateAddress.PostalCode = safePostalCode;
                }
                _EstimateAddress.Residence = _User.IsAnonymous ? !this.AssumeCommercialRates : _BillingAddress.Residence;

                // PREPARE AND DISPLAY THE RATE QUOTE INFORMATION
                phResultPanel.Visible            = true;
                MultipleShipmentsMessage.Visible = this.MultiShipmentDisplay;
                ShipmentList.DataSource          = _Basket.Shipments;
                ShipmentList.DataBind();
            }
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            // LOCATE THE USER THAT THE ORDER IS BEING PLACED FOR
            _UserId = AlwaysConvert.ToInt(Request.QueryString["UID"]);
            _User   = UserDataSource.Load(_UserId);
            if (_User == null)
            {
                Response.Redirect("CreateOrder1.aspx");
            }
            _Basket = _User.Basket;
            MiniBasket1.BasketId = _Basket.Id;
            if (!Page.IsPostBack)
            {
                IBasketService preCheckoutService = AbleContext.Resolve <IBasketService>();
                preCheckoutService.Recalculate(_Basket);
            }

            // INITIALIZE THE CAPTION
            string userName = _User.IsAnonymous ? "Unregistered User" : _User.UserName;

            Caption.Text = string.Format(Caption.Text, userName);

            // SHOW BILLING ADDRESS
            BillToAddress.Text             = _User.PrimaryAddress.ToString(true);
            EditAddressesLink.NavigateUrl += "?UID=" + _UserId;

            // SHOW REGISTRATION PANEL IF USER IS ANONYMOUS
            if (_User.IsAnonymous)
            {
                RegisterPanel.Visible = true;
                string       billToEmail   = _User.PrimaryAddress.Email;
                IList <User> matchingUsers = UserDataSource.LoadForEmail(billToEmail, false);
                bool         userExists    = (matchingUsers.Count > 0);
                if (userExists)
                {
                    _ExistingUser        = matchingUsers[0];
                    AccountUserName.Text = _ExistingUser.UserName;
                    AccountEmail.Text    = _ExistingUser.Email;
                }
                else
                {
                    AccountUserName.Text = billToEmail;
                    AccountEmail.Text    = billToEmail;
                }
                RegisteredUserHelpText.Visible   = userExists;
                UnregisteredUserHelpText.Visible = !userExists;
                LinkAccountLabel.Visible         = userExists;
                CreateAccountLabel.Visible       = !userExists;
                trAccountPassword.Visible        = !userExists;
                trForceExpiration.Visible        = !userExists;
            }

            // SHOW SHIPPING METHODS IF NECESSARY
            ShippingMethodPanel.Visible = _Basket.Items.HasShippableProducts();
            if (ShippingMethodPanel.Visible)
            {
                tdShipTo.Visible = true;
                Address shipAddress = this.ShippingAddress;
                if (shipAddress != null)
                {
                    ShipToAddress.Text = shipAddress.ToString(true);
                }
                if (!Page.IsPostBack)
                {
                    // ONLY BIND SHIPMENT LIST ON FIRST VISIT
                    ShipmentList.DataSource = _Basket.Shipments;
                    ShipmentList.DataBind();
                }
            }
        }
 /// <summary>
 /// Handles the OnNeedRebind event of the ShipmentList control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="oArgs">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 public void ShipmentList_OnNeedRebind(object sender, System.EventArgs oArgs)
 {
     ShipmentList.DataBind();
 }