protected virtual void populateShipping(DropDownList dropdownNickName) { dropdownNickName.Visible = true; dropdownNickName.Items.Clear(); var tempSortedShippingAddresses = new List <DeliveryOption>(); //Apply Sorting rules if (_shippingAddresses.Exists(s => s.IsPrimary)) { tempSortedShippingAddresses.Add(_shippingAddresses.Where(s => s.IsPrimary).FirstOrDefault()); } tempSortedShippingAddresses.AddRange(_shippingAddresses. Where(s => !string.IsNullOrEmpty(s.Alias) && !s.IsPrimary) .OrderBy(a => a.Alias)); tempSortedShippingAddresses.AddRange(_shippingAddresses. Where(s => string.IsNullOrEmpty(s.Alias) && !s.IsPrimary) .OrderBy(a => a.DisplayName)); if (HLConfigManager.Configurations.AddressingConfiguration.HasAddressRestriction) { tempSortedShippingAddresses = new List <DeliveryOption>(); tempSortedShippingAddresses.AddRange(_shippingAddresses.Where(x => x.HasAddressRestriction ?? false)); } dropdownNickName.DataSource = tempSortedShippingAddresses; dropdownNickName.DataBind(); if (tempSortedShippingAddresses.Count == 0) { if ((ShoppingCart.OrderCategory == ServiceProvider.CatalogSvc.OrderCategoryType.ETO && !HLConfigManager.Configurations.DOConfiguration.ShowOrderQuickViewForEventTicket) || APFDueProvider.ShouldHideOrderQuickView(ShoppingCart)) { //Leave the cart alone } else { ShoppingCart.DeliveryInfo = null; } showHideAddressLink(); } if (dropdownNickName.SelectedItem != null) { if (ShoppingCart.DeliveryInfo != null && ShoppingCart.DeliveryInfo.Address != null && tempSortedShippingAddresses.Count > dropdownNickName.SelectedIndex && ShoppingCart.DeliveryInfo.Address.ID == tempSortedShippingAddresses[dropdownNickName.SelectedIndex].ID) { ShoppingCart.DeliveryInfo.Address = tempSortedShippingAddresses[dropdownNickName.SelectedIndex]; } } }