如何解决尝试在控制器内调用绑定下拉列表的方法
我试图通过在控制器内的动作方法内调用方法来绑定下拉列表。
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”。
任何想法都会受到赞赏。
解决方法
您不能通过调用List<Ipcell>
List<string>
转换为.ToString()
您需要将函数bindType()
的返回类型设置为List<Ipcell>
。这样,您还需要将ddltype
的类型更改为List<Ipcell>
,以便代码可以正确编译。
您以后可以将Ipcell
(Ipcell.CaseId
和Ipcell.Type
)中的值用于绑定目的。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。