protected void BindGrid() { var countryCollection = this.CountryService.GetAllCountries(); var paymentMethodCollection = this.PaymentService.GetAllPaymentMethods(null, false); if(countryCollection.Count == 0) { lblMessage.Text = GetLocaleResourceString("Admin.PaymentMethodsFilterControl.NoCountryDefined"); } if(paymentMethodCollection.Count == 0) { lblMessage.Text = GetLocaleResourceString("Admin.PaymentMethodsFilterControl.NoPaymentMethodDefined"); } List<PaymentMethodCountryMappingHelperClass> dt = new List<PaymentMethodCountryMappingHelperClass>(); foreach(Country country in countryCollection) { PaymentMethodCountryMappingHelperClass map1 = new PaymentMethodCountryMappingHelperClass(); map1.CountryId = country.CountryId; map1.CountryName = country.Name; map1.Restrict = new Dictionary<int, bool>(); foreach(PaymentMethod paymentMethod in paymentMethodCollection) { map1.Restrict.Add(paymentMethod.PaymentMethodId, this.PaymentService.DoesPaymentMethodCountryMappingExist(paymentMethod.PaymentMethodId, country.CountryId)); } dt.Add(map1); } gvPaymentMethodCountryMap.DataSource = dt; gvPaymentMethodCountryMap.DataBind(); }
protected void BindGrid() { CountryCollection countryCollection = CountryManager.GetAllCountries(); PaymentMethodCollection paymentMethodCollection = PaymentMethodManager.GetAllPaymentMethods(null, false); if (countryCollection.Count == 0) { lblMessage.Text = GetLocaleResourceString("Admin.PaymentMethodsFilterControl.NoCountryDefined"); } if (paymentMethodCollection.Count == 0) { lblMessage.Text = GetLocaleResourceString("Admin.PaymentMethodsFilterControl.NoPaymentMethodDefined"); } List <PaymentMethodCountryMappingHelperClass> dt = new List <PaymentMethodCountryMappingHelperClass>(); foreach (Country country in countryCollection) { PaymentMethodCountryMappingHelperClass map1 = new PaymentMethodCountryMappingHelperClass(); map1.CountryId = country.CountryId; map1.CountryName = country.Name; map1.Restrict = new Dictionary <int, bool>(); foreach (PaymentMethod paymentMethod in paymentMethodCollection) { map1.Restrict.Add(paymentMethod.PaymentMethodId, PaymentMethodManager.DoesPaymentMethodCountryMappingExist(paymentMethod.PaymentMethodId, country.CountryId)); } dt.Add(map1); } gvPaymentMethodCountryMap.DataSource = dt; gvPaymentMethodCountryMap.DataBind(); }
private void hfCountryId_DataBinding(Object sender, EventArgs e) { HiddenField hf = sender as HiddenField; GridViewRow row = hf.NamingContainer as GridViewRow; PaymentMethodCountryMappingHelperClass map1 = row.DataItem as PaymentMethodCountryMappingHelperClass; hf.Value = map1.CountryId.ToString(); }
private void ctrl_DataBinding(Object sender, EventArgs e) { WebControl ctrl = sender as WebControl; GridViewRow row = ctrl.NamingContainer as GridViewRow; switch (_dataType) { case "String": object RawValue = DataBinder.Eval(row.DataItem, _columnName); (ctrl as Label).Text = RawValue.ToString(); break; case "Checkbox": PaymentMethodCountryMappingHelperClass map1 = row.DataItem as PaymentMethodCountryMappingHelperClass; PaymentMethod pm = PaymentMethodManager.GetPaymentMethodById(_paymentMethodId); if (pm != null) { switch (pm.PaymentMethodType) { case PaymentMethodTypeEnum.Unknown: case PaymentMethodTypeEnum.Standard: { (ctrl as CheckBox).Checked = map1.Restrict[_paymentMethodId]; } break; case PaymentMethodTypeEnum.Button: { (ctrl as CheckBox).Enabled = false; (ctrl as CheckBox).Text = "n/a"; } break; default: break; } } break; } }