我有一个枚举类,并尝试将值绑定到Kendo DropDownListFor,如下所示。但是,只有" undefined"因为ddl和I的值无法管理枚举值。有可能吗?
枚举:
public enum Country
{
[Description("United States")]
US = 1,
[Description("United Kingdom")]
UK = 2,
[Description("New Zealand")]
NewZealand = 3,
[Description("France")]
France = 4,
[Description("Germany")]
Germany = 5
}
的型号:
public class Tourist
{
[Key]
public int ID { get; set; }
//I used enums like that in order to display the multiple word values i.e. United States
public Country Country { get; set; }
[NotMapped]
public string CountryeName
{
get { return MyEnumHelper.GetDescription(Country); }
}
//code omitted for brevity
}
查看:
@(Html.Kendo().DropDownListFor(m => m.Country)
.DataTextField("Country")
.DataValueField("Country")
.OptionLabel("Select")
.BindTo(Enum.GetNames(typeof(Country)).ToList())
)