private void BindLanguages() { var languages = this.LanguageService.GetAllLanguages(); if (languages.Count > 1) { var customerLanguage = NopContext.Current.WorkingLanguage; Visible = true; if (this.SettingManager.GetSettingValueBoolean("Common.UseImagesForLanguageSelection", false)) { rptLanguages.Visible = true; ddlLanguages.Visible = false; List <RptLanguageItem> itemList = new List <RptLanguageItem>(); foreach (var language in languages) { RptLanguageItem item = new RptLanguageItem(); item.Class = (language.LanguageId == customerLanguage.LanguageId ? "selected" : String.Empty); item.ImageUrl = language.IconUrl; item.LanguageID = language.LanguageId; item.Name = language.Name; itemList.Add(item); } rptLanguages.DataSource = itemList; rptLanguages.DataBind(); } else { rptLanguages.Visible = false; ddlLanguages.Visible = true; ddlLanguages.Items.Clear(); foreach (var language in languages) { var item = new ListItem(language.Name, language.LanguageId.ToString()); ddlLanguages.Items.Add(item); } if (customerLanguage != null) { CommonHelper.SelectListItem(ddlLanguages, customerLanguage.LanguageId); } } } else { Visible = false; } }
private void BindLanguages() { var languages = LanguageManager.GetAllLanguages(); if(languages.Count > 1) { var customerLanguage = NopContext.Current.WorkingLanguage; Visible = true; if(SettingManager.GetSettingValueBoolean("Common.UseImagesForLanguageSelection", false)) { rptLanguages.Visible = true; ddlLanguages.Visible = false; List<RptLanguageItem> itemList = new List<RptLanguageItem>(); foreach(var language in languages) { RptLanguageItem item = new RptLanguageItem(); item.Class = (language.LanguageId == customerLanguage.LanguageId ? "selected" : String.Empty); item.ImageUrl = language.IconUrl; item.LanguageID = language.LanguageId; item.Name = language.Name; itemList.Add(item); } rptLanguages.DataSource = itemList; rptLanguages.DataBind(); } else { rptLanguages.Visible = false; ddlLanguages.Visible = true; ddlLanguages.Items.Clear(); foreach(var language in languages) { var item = new ListItem(language.Name, language.LanguageId.ToString()); ddlLanguages.Items.Add(item); } if(customerLanguage != null) { CommonHelper.SelectListItem(ddlLanguages, customerLanguage.LanguageId); } } } else { Visible = false; } }