从数据表创建下拉列表

问题描述

我想基于一个表创建一个下拉列表,其中的值来自我的 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" })