Data binding 剑道下拉绑定

Data binding 剑道下拉绑定,data-binding,enums,kendo-ui,dropdown,Data Binding,Enums,Kendo Ui,Dropdown,我有这个枚举: public enum PayTerms { [Display(Name = "30")] _30 = 1, [Display(Name = "60")] _60, [Display(Name = "90")] _90, [Display(Name = "120")] _120,

我有这个枚举:

public enum PayTerms
    {       
        [Display(Name = "30")]
        _30 = 1,        
        [Display(Name = "60")]
        _60,        
        [Display(Name = "90")]
        _90,        
        [Display(Name = "120")]
        _120,        
        CAD
    }
使用此模板,我可以创建具有专有名称的下拉列表:

@model PayTerms?

<div class="k-edit-label">@Html.LabelFor(x => x)</div>
<div class="k-edit-field">
    @(Html.Kendo().DropDownListFor(m => m)
        .BindTo(EnumHelper.GetSelectList(typeof(PayTerms)))
        .OptionLabel("-- Select --"))
</div>
@型号付款条件?
@LabelFor(x=>x)
@(Html.Kendo().DropDownListFor(m=>m)
.BindTo(EnumHelper.GetSelectList(typeof(PayTerms)))
.OptionLabel(“--Select-->”)
但我在绑定方面有问题。当前,对于“我的枚举”属性的每个值,下拉列表中的选定值为“-Select--” 如何将下拉列表的选定值绑定到枚举值

更新:


我也尝试过EnumHelper.GetSelectList(typeof(Erp.Shared.Contract.PayTerms),Model.Value),但也没有运气

Kendo MVC helper与enum有问题,因为它无法确定是绑定到enum的整数表示还是字符串表示。默认的MVC下拉列表没有这样的问题

尝试将显式.Value()添加到定义中:

@(Html.Kendo().DropDownListFor(m => m)
    .BindTo(EnumHelper.GetSelectList(typeof(PayTerms)))
    .Value(((int) Model).ToString())
    .OptionLabel("-- Select --"))

Kendo MVC helper在枚举方面存在问题,因为它无法确定是绑定到枚举的整数表示还是字符串表示。默认的MVC下拉列表没有这样的问题

尝试将显式.Value()添加到定义中:

@(Html.Kendo().DropDownListFor(m => m)
    .BindTo(EnumHelper.GetSelectList(typeof(PayTerms)))
    .Value(((int) Model).ToString())
    .OptionLabel("-- Select --"))