没有类型为'IEnumerable< SelectListItem>'的ViewData项具有键'UserName'。 [英] There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'UserName'.

查看:200
本文介绍了没有类型为'IEnumerable< SelectListItem>'的ViewData项具有键'UserName'。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我上面提到并且无法确定究竟是什么错误。

代码对其他代码工作正常,但只有单个表我才会收到错误。

请帮助

这是控制器代码

I'm getting above mention and not able to figure out what exactly error is.
code is working fine for other but only for a single table i'm getting error.
Please help
This is controller code

ViewBag.User = new SelectList(context.Users, "UserName", "UserName");





这是查看代码。



this is View code.

@Html.DropDownList("UserName", (IEnumerabl<SelectListItem>)ViewBag.User, "Select User")







请帮助




Please help

推荐答案

我认为应该是...

I think that should be...
@Html.DropDownList("UserName", ViewBag.User, "Select User")


这篇关于没有类型为'IEnumerable&lt; SelectListItem&gt;'的ViewData项具有键'UserName'。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆