微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

从数据表创建下拉列表

如何解决从数据表创建下拉列表

我想基于一个表创建一个下拉列表,其中的值来自我的 Table_Services 并保存在我的 Table_Status 服务中

IMG

目前我有这个:

import functools

from pyspark.sql.functions import lit,col,when

case_conditions = list(zip(product_code,product_name))

product_col = functools.reduce(
    lambda acc,x: acc.when(col(f"input_file_name").like(x[1]),lit(x[1])),case_conditions[1:],when(col("input_file_name").like(case_conditions[0][0]),lit(case_conditions[0][1]))
).otherwise(col("Feed_name"))

df.withColumn("Product",product_col).show()

我尝试创建一个列表,但没有成功:(

我的模型:

@Html.TextBoxFor(m => @item.Status,new { @class = "Status",disabled = true }) //from my Table_Status

控制器:

public List<Table_Services> ServicesList { get; set; }

查看:

Orderviewmodel model = new Orderviewmodel
        {
            ServicesList = db.Table_Services.ToList()
        };

谢谢,

解决方法

您错过了 Html.DropDownListFor 上的 dataValueField

@Html.DropDownListFor(model => @item.Status,new SelectList(Model.ServicesList,"ID","Services","Select One"),new { @class = "form-control col-md-12" })

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。