protected void BindGrid() { var countryCollection = CountryManager.GetAllCountries(); var shippingMethodCollection = ShippingMethodManager.GetAllShippingMethods(); if(countryCollection.Count == 0) { lblMessage.Text = GetLocaleResourceString("Admin.ShippingMethodsFilterControl.NoCountryDefined"); } if(shippingMethodCollection.Count == 0) { lblMessage.Text = GetLocaleResourceString("Admin.ShippingMethodsFilterControl.NoShippingMethodDefined"); } List<ShippingMethodCountryMappingHelperClass> dt = new List<ShippingMethodCountryMappingHelperClass>(); foreach(Country country in countryCollection) { ShippingMethodCountryMappingHelperClass map1 = new ShippingMethodCountryMappingHelperClass(); map1.CountryId = country.CountryId; map1.CountryName = country.Name; map1.Restrict = new Dictionary<int, bool>(); foreach(ShippingMethod shippingMethod in shippingMethodCollection) { map1.Restrict.Add(shippingMethod.ShippingMethodId, ShippingMethodManager.DoesShippingMethodCountryMappingExist(shippingMethod.ShippingMethodId, country.CountryId)); } dt.Add(map1); } gvShippingMethodCountryMap.DataSource = dt; gvShippingMethodCountryMap.DataBind(); }
protected void BindGrid() { var countryCollection = CountryManager.GetAllCountries(); var shippingMethodCollection = ShippingMethodManager.GetAllShippingMethods(); if (countryCollection.Count == 0) { lblMessage.Text = GetLocaleResourceString("Admin.ShippingMethodsFilterControl.NoCountryDefined"); } if (shippingMethodCollection.Count == 0) { lblMessage.Text = GetLocaleResourceString("Admin.ShippingMethodsFilterControl.NoShippingMethodDefined"); } List <ShippingMethodCountryMappingHelperClass> dt = new List <ShippingMethodCountryMappingHelperClass>(); foreach (Country country in countryCollection) { ShippingMethodCountryMappingHelperClass map1 = new ShippingMethodCountryMappingHelperClass(); map1.CountryId = country.CountryId; map1.CountryName = country.Name; map1.Restrict = new Dictionary <int, bool>(); foreach (ShippingMethod shippingMethod in shippingMethodCollection) { map1.Restrict.Add(shippingMethod.ShippingMethodId, ShippingMethodManager.DoesShippingMethodCountryMappingExist(shippingMethod.ShippingMethodId, country.CountryId)); } dt.Add(map1); } gvShippingMethodCountryMap.DataSource = dt; gvShippingMethodCountryMap.DataBind(); }
private void hfCountryId_DataBinding(Object sender, EventArgs e) { HiddenField hf = sender as HiddenField; GridViewRow row = hf.NamingContainer as GridViewRow; ShippingMethodCountryMappingHelperClass map1 = row.DataItem as ShippingMethodCountryMappingHelperClass; 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": ShippingMethodCountryMappingHelperClass map1 = row.DataItem as ShippingMethodCountryMappingHelperClass; (ctrl as CheckBox).Checked = map1.Restrict[_shippingMethodId]; break; } }