The code snippets below provide examples for how to programatically access Umbraco data types with pre values, for example the Umbraco drop down list:
using System.Collections; using umbraco.cms.businesslogic.datatype; var values = PreValues.GetPreValues(YOUR_DATA_TYPE_ID_HERE); foreach (DictionaryEntry de in values) { PreValue value = (PreValue)de.Value; ListItem li = new ListItem(); li.Text = value.Value; li.Value = value.Id.ToString(); dropDownList.Items.Add(li); }
The above code queries Umbraco for the pre-values for the data type you specify and returns a collection of DictionaryEntry's. We then loop through, adding list items to your drop down list.
dropDownList.SelectedItem.Value
Simply get the selected item's value using the code above and save it in the node.