尝试在控制器内调用绑定下拉列表的方法

时间:2020-09-01 05:21:30

标签: c# asp.net-mvc

我试图通过在控制器内的动作方法内调用方法来绑定下拉列表。

public ActionResult Ipcell(Int id)
{
List<string> ddltype = bindtype();
}
private List<string> bindtype()
{
    List<Ipcell> result = new List<Ipcell>();
    conn.Open();
    string qry = "select icd_type from SE_DTLS";
    OracleCommand command = new OracleCommand(qry, conn);
    OracleDataReader reader = command.ExecuteReader();
    while (reader != null && reader.Read())
    {
        Ipcell member = new Ipcell();
        member.CaseId = reader[0].ToString();
        member.Type = reader[1].ToString();
        result.Add(member);
    }
    return result.ToString();
}

Ipcell是模型类 但在返回result.ToString();

时出错

”无法隐式转换类型'System.Collections.Generic.List 到system.collections.Generic.List”。

任何想法都会受到赞赏。

1 个答案:

答案 0 :(得分:0)

您不能通过调用List<Ipcell>

直接将List<string>转换为.ToString()

您需要将函数bindType()的返回类型设置为List<Ipcell>。这样,您还需要将ddltype的类型更改为List<Ipcell>,以便代码可以正确编译。

您以后可以将IpcellIpcell.CaseIdIpcell.Type)中的值用于绑定目的。

相关问题