The ability to add custom fields to an existing content module in Sitefinity CMS provides flexibility to achieve a various range of scenarios.
One of these fields is the Choice Field. It allows users to select one of the predefined values, which can later be accessed via code, and, for example, provide filtering based on this field on the frontend. However, if we want to have a drop down containing all the possible values of the field, they need to be hardcoded manually.
To avoid doing this and to prevent typos, we can use the API to tap directly into the definitions and pull all the values from there, allowing us to bind them to a drop down for example.
First, we need to get one of the backend views (Edit/Insert) and from there we will have access to the CustomFieldsSection and the field we are after.
var conf = Config.Get<LibrariesConfig>();
var viewDef = conf.ContentViewControls[
var section = viewDef.Sections[
var mcFieldDefinition = section.Fields[
var choices = mcFieldDefinition.Choices;
> collection =
Dropdownlist1.DataSource = collection;