In order to implement this behivor on my theme I use DotNetNuke.Common.Utilities.Config class.
- First I create an App Setting in the dnn web.config.
You can do this manually:
<add key="DropDownListValues" value="Value1,Value2,Value3" />
...or you can add these values from code:
public static void AddAppSetting(string name, string value)
{
var xmlDocument = DotNetNuke.Common.Utilities.Config.AddAppSetting(DotNetNuke.Common.Utilities.Config.Load(), name, value);
DotNetNuke.Common.Utilities.Config.Save(xmlDocument);
}
Having this property you can always populate your DropDownList this way:
var stylesCommaSeparated = DotNetNuke.Common.Utilities.Config.GetSetting("DropDownListValues");
stylesCommaSeparated.Split(',').ForEach(setting=>DropDownList1.Items.Add(setting));