Issue with enums and dropdownlist control

2 posts, 0 answers
  1. Heath
    Heath avatar
    1 posts
    Member since:
    Feb 2015

    Posted 01 Oct 2015 Link to this post

    Starting with the Q3 release we've seen the following behavior for enum attributes that are bound to a dropdownlist.

    1.  Attribute in model is of type enum
    2. select values passed to the dropdownlist are of type IEnumerable<SelectListItem> with the value of the attribute set as selected.
    3. The dropDownList is populated using .BindTo so is loaded on page load
    4. When the form opens no value is selected in dropdown.  This happens in all cases where a dropdownlist is bound to an enum

    I did some testing and found when I bound the dropdownlist to the integer that the enum represented, the dropdownlist worked as expected.  It seems that the control is no longer binding to enums as it did before (binding the value to the integer the enum represents).  Did something change that was undocumented in the Q3 release that caused this behavior?

  2. Georgi Krustev
    Georgi Krustev avatar
    3725 posts

    Posted 05 Oct 2015 Link to this post


    In general, the widget is designed to select an item based on the value. This mapping is done using DataValueField option. Indeed, before widget was selecting Enum value using its string representation, but this behavior had been working by chance. The correct way to select widget's value is to use int value of the Enum. Check the attached test demo.

    The change was introduced in Q2 2015 release when we added support for selecting value honoring datasource item type.

    Georgi Krustev
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top