我试图通过在控制器内的动作方法内调用方法来绑定下拉列表。
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”。
任何想法都会受到赞赏。
答案 0 :(得分:0)
您不能通过调用List<Ipcell>
List<string>
转换为.ToString()
您需要将函数bindType()
的返回类型设置为List<Ipcell>
。这样,您还需要将ddltype
的类型更改为List<Ipcell>
,以便代码可以正确编译。
您以后可以将Ipcell
(Ipcell.CaseId
和Ipcell.Type
)中的值用于绑定目的。