【问题标题】:How to store more model properties in SelectList如何在 SelectList 中存储更多模型属性
【发布时间】:2015-11-05 12:50:24
【问题描述】:

我有一个包含字段的类 ParameterDetails:

    public long? ID
    {
        get;
        set;
    }
    public long? ParameterID
    {
        get;
        set;
    }
    public string Unit
    {
        get;
        set;
    }
    public long? DataType
    {
        get;
        set;
    }

现在我根据 ParameterDetails 类元素的列表创建一个 SelectList:

 @Html.DropDownListFor(m => Model.ParameterDetails.ID, new SelectList(
    Model.ParameterDetailsList.AsEnumerable(), "ID", "Unit"), new
    {
        @class = "form-control unit-dropdown dropdown",
        id = String.Format("Unit{0}", Model.Parameter.ID),
        onchange = "changeValidation(this);"
    })

现在的问题是: 如何从javascript“changeValidation”函数访问ID和UNIT以外的其他字段??? 当我从选择列表中选择新项目时,我需要 DataType 属性来更改 html“data-val-regex”属性

【问题讨论】:

    标签: javascript view properties store selectlist


    【解决方案1】:

    使用 AJAX 解决了一些问题。我调用了一个方法,从控制器获取数据,然后将其发送到 Json 对象中以查看。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多