Kendo 下拉绑定

Kendo dropdown binding

我有这个枚举:

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>

但是我在绑定方面遇到了问题。目前,对于我的枚举 属性 的每个值,下拉列表中的选定值是“--Select--” 如何将下拉列表的选定值绑定到枚举值?

更新:

我也试过EnumHelper.GetSelectList(typeof(Erp.Shared.Contract.PayTerms), Model.Value)但是还是不行

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

http://www.telerik.com/forums/problem-binding-enum-to-dropdownlist#ZabuB0_2A0OserEwBh_etQ

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

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