I have create enum type property but it is not design a drop down list - General Discussions - General Discussions - Progress Community

I have create enum type property but it is not design a drop down list

 General Discussions

I have create enum type property but it is not design a drop down list

  • I have create enum type property but it is not design a drop down list
  • below is the property which i was define,
    please find the attached screen shots where I am only getting first value of enum property in text box.

     public ColorType Color get; set;
     public enum ColorType Black, Blue, Red, Green, Purple, Gray, Yellow


    I am using sitefinity version 5.2.

    actually I want property data appear in drop down list when i clicked at usercontrol edit option.
  • Hi Suyash,

    You could try to use this code to bind to the DropDownList:

    Array itemValues = System.Enum.GetValues(typeof(ColorType));
    Array itemNames = System.Enum.GetNames(typeof(ColorType));
     
    for (int i = 0; i <= itemNames.Length - 1 ; i++)
        ListItem item = new ListItem(itemNames[i], itemValues[i]);
        dropdownlist.Items.Add(item);

    Kind regards,
    Daniel
  • Hello,

    Thank you Danie for sharing a solution. I hope that Suyash will find it useful.

    Regards,
    Stefani Tacheva
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items