logo

Adding an element to a drop-down list

Here we show an example of a script for adding an item to a List context variable of the drop-down list type.

Script text:
var ddlSettings = context.GetSettingsFor(m => m.Spisok).As<DropDownListSettings>();
//ddlSettings.Items.Clear(); //clean drop-down list
ddlSettings.Items.Add(new DropDownItem("new item"));
ddlSettings.Save();