How to provide dropdown with 1 to 9 directly, and 5 as default

I need a dropdown with 1,2,3,4,5,6,7,8,9 to show for user to pick, and the default is 5, as string.
It is to say, if user didn't select, as dropdown showing 5 as initial state, system would take 5 as default, as bind value.

Kindly advise. Thanks in advance.

Currently I have working feature using textbox as follows. Need to turn textbox to dropdown

        public void OnPriorityChange(string value, string name)
        {
             try
            {
                var temp = Int32.Parse(value);
                if (temp < 1 || temp > 9)
                {
                    txtNEW_PRTY = "5";
                    NotificationService.Notify(new NotificationMessage { Severity = NotificationSeverity.Info, Summary = "Must be 1 to 9, default is 5" });

                }
                else
                {
                    txtNEW_PRTY = "" + temp;
                }
               

            }
            catch
            {
                txtNEW_PRTY = "5";
                NotificationService.Notify(new NotificationMessage { Severity = NotificationSeverity.Info, Summary = "Must be 1 to 9, default is 5" });
            }
        }

You can try setting the Data property of the DropDown to a string array which contains the required values. Then set the Value property to a page field with the default.

I have problem to assign simple 1 to 9 to Data property.
Could you kindly show me sample code or reference doc?
The one I could find was with entity

  1. Create a page property which contains the desired values.
  2. Create a page property which will contain the dropdown value (and the initial one)
  3. Set the Data and Value properties of the DropDown.

Sample application is attached.dropdown.zip (4.9 KB)

2 Likes

Exactly what I needed too, thanks!