EditingComponent DropDown Datasource Questions

Suneel Jhangiani asked on March 10, 2023 17:19

I currently have the following code for a components property to be shown as a drop down.

public const string MY_DATASOURCE = "1;Value1\r\n2;Value2\r\n3;Value3"

EditingComponent(DropDownComponent.IDENTIFIER, DefaultValue = "1", Label = "Properties.Field.Name", Order = 1)]
EditingComponentProperty(nameof(DropDownProperties.DataSource), myDropDown.DATASOURCE)]
public string FieldName { get; set; }

What I would like to know is if there is a simple way to bind this to a Enum? Also, what is the recommended way to localize the datasource?

Recent Answers

Liam Goldfinch answered on March 11, 2023 02:28


So for the first point, you can create a custom dropdown form component that loads in values from an enum maybe using a custom General Selector form component, or just a bespoke drop down component.

You'd configure it so you can specify an enum, and then use Enum.GetNames() or Enum.GetValues() to bind the names/values to the dropdown list of items.

For the second point, if you want to have localised values in the datasource, you can use a macro syntax like this:


This is an example of one that Kentico uses for the Recaptcha form component.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.