Esempio n. 1
0
        // internal static void BindListInternal(DropDownList comboBox, object value, IEnumerable listSource, string textField, string valueField)
        internal static void BindListInternal(DnnComboBox comboBox, object value, IEnumerable listSource, string textField, string valueField)
        {
            if (comboBox != null)
            {
                string selectedValue = !comboBox.Page.IsPostBack ? Convert.ToString(value) : comboBox.SelectedValue;

                if (listSource is Dictionary <string, string> )
                {
                    var items = listSource as Dictionary <string, string>;
                    foreach (var item in items)
                    {
                        // comboBox.Items.Add(new ListItem(item.Key, item.Value));
                        comboBox.AddItem(item.Key, item.Value);
                    }
                }
                else
                {
                    comboBox.DataTextField  = textField;
                    comboBox.DataValueField = valueField;
                    comboBox.DataSource     = listSource;

                    comboBox.DataBind();
                }

                // Reset SelectedValue
                // comboBox.Select(selectedValue);
                var selectedItem = comboBox.FindItemByValue(selectedValue);
                if (selectedItem != null)
                {
                    selectedItem.Selected = true;
                }
            }
        }
        //internal static void BindListInternal(DropDownList comboBox, object value, IEnumerable listSource, string textField, string valueField)
        internal static void BindListInternal(DnnComboBox comboBox, object value, IEnumerable listSource, string textField, string valueField)
        {
            if (comboBox != null)
            {
                string selectedValue = !comboBox.Page.IsPostBack ? Convert.ToString(value) : comboBox.SelectedValue;

                if (listSource is Dictionary<string, string>)
                {
                    var items = listSource as Dictionary<string, string>;
                    foreach (var item in items)
                    {
                        //comboBox.Items.Add(new ListItem(item.Key, item.Value));
                        comboBox.AddItem(item.Key, item.Value);
                    }
                }
                else
                {
                    comboBox.DataTextField = textField;
                    comboBox.DataValueField = valueField;
                    comboBox.DataSource = listSource;

                    comboBox.DataBind();
                }

                //Reset SelectedValue
                //comboBox.Select(selectedValue);
                var selectedItem = comboBox.FindItemByValue(selectedValue);
                if (selectedItem != null)
                    selectedItem.Selected = true;                
            }
        }
 public static void Init (PortalModuleBase module, DnnComboBox comboWorkingHours)
 {
     // fill working hours terms
     var termCtrl = new TermController ();
     var workingHours = termCtrl.GetTermsByVocabulary ("University_WorkingHours").ToList ();
     workingHours.Insert (0, new Term (Localization.GetString ("NotSelected.Text", module.LocalResourceFile)));
     comboWorkingHours.DataSource = workingHours;
     comboWorkingHours.DataBind ();
 }
Esempio n. 4
0
        public void BindData(bool refresh)
        {
            if (refresh)
            {
                List <CultureInfo> cultures;
                switch (LanguagesListType)
                {
                case LanguagesListType.Supported:
                    cultures = LocaleController.Instance.GetCultures(LocaleController.Instance.GetLocales(Null.NullInteger));
                    break;

                case LanguagesListType.Enabled:
                    cultures = LocaleController.Instance.GetCultures(LocaleController.Instance.GetLocales(PortalId));
                    break;

                default:
                    cultures = new List <CultureInfo>(CultureInfo.GetCultures(CultureTypes.SpecificCultures));
                    break;
                }

                foreach (KeyValuePair <string, Locale> lang in HideLanguagesList)
                {
                    string      cultureCode = lang.Value.Code;
                    CultureInfo culture     = cultures.Where(c => c.Name == cultureCode).SingleOrDefault();
                    if (culture != null)
                    {
                        cultures.Remove(culture);
                    }
                }

                _nativeCombo.DataSource  = cultures.OrderBy(c => c.NativeName);
                _englishCombo.DataSource = cultures.OrderBy(c => c.EnglishName);
            }


            _nativeCombo.DataBind();
            _englishCombo.DataBind();

            if (IncludeNoneSpecified && refresh)
            {
                _englishCombo.Items.Insert(0, new RadComboBoxItem(Localization.GetString("System_Default", Localization.SharedResourceFile), "None"));
                _nativeCombo.Items.Insert(0, new RadComboBoxItem(Localization.GetString("System_Default", Localization.SharedResourceFile), "None"));
            }
        }
        private void LoadFiles()
        {
            int effectivePortalId = PortalId;
            var user = User ?? UserController.GetCurrentUserInfo();

            if (IsUserFolder(FoldersComboBox.SelectedItem.Value))
            {
                if (!user.IsSuperUser)
                {
                    effectivePortalId = PortalController.GetEffectivePortalId(effectivePortalId);
                }
                else
                {
                    effectivePortalId = -1;
                }
            }
            FilesComboBox.DataSource = DotNetNuke.Common.Globals.GetFileList(effectivePortalId, FileFilter, Required, FoldersComboBox.SelectedItem.Value);
            FilesComboBox.DataBind();
        }