SelectionFactory set Initial/Default value and display it's placeholder in select/dropdown box


Hi all,

I found this topic here - - but none of the solutions solves my problem.

I have this property on a page, which uses custom Selection Factory.

And I want to set initial value and display it's placeholder (in admin view, under "All properties" view while creating new page) here in a select box. I do it like this:

// CustomSelectionFactory.cs:

public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
    List<SelectItem> result = new List<SelectItem>()
        new SelectItem() { Text = "All", Value = null }

    List<CustomSelectItem> customSelectItems = new List<CustomSelectItem>();

    switch (metadata.PropertyName)
        case "DocumentCountry":
            customSelectItems = Api.GetCustomSelectItems(1).Result; 
        case "DocumentLanguage":
            customSelectItems = Api.GetCustomSelectItems(2).Result; 
            result.RemoveAll(x => x.Text == "All");
            metadata.InitialValue = "1";

    foreach (CustomSelectItems customSelectItem in customSelectItems)
        result.Add(new SelectItem()
            Text = customSelectItem .Name,
            Value = customSelectItem .Id.ToString()

    return result;

// CustomPage.cs

[Display(Name = "Document Country")]
[SelectOne(SelectionFactoryType = typeof(CustomSelectionFactory))]
public virtual string DocumentCountry { get; set; }

[Display(Name = "Document Language")]
[SelectOne(SelectionFactoryType = typeof(CustomSelectionFactory))]
public virtual string DocumentLanguage { get; set; }

Help appreciated!

Edited, Oct 23, 2019 13:37


You can set the default value.

public override void SetDefaultValues(ContentType contentType)
    //Set values here
Oct 23, 2019 12:15
fuji - Oct 23, 2019 13:50
Ok, now this worked (even without setting "metadata.InitialValue = "1";" in "CustomSelectionFactory.cs", the issue was probably because "DocumentLanguage" property was of type "int?". Thank you!

@Ravindra S. Rathore,

I think I have tried it and it partly works - on publish it passes further the default value, but the placeholder of selectbox is still empty

Oct 23, 2019 12:17

Placeholder in CMS or on the front-end site?

Oct 23, 2019 12:31
fuji - Oct 23, 2019 12:42
In admin view, under "All properties" view while creating new page, so I guess it's CMS? :D
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.