TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rich
NA
84
61.2k
MVC SelectList error
May 14 2012 6:36 PM
I have a SelectList that I have passed into a form in my view. When I try to post it I get this error:
There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'roleName'.
Code in Controller:
ViewBag.roleName = new SelectList(Roles.GetAllRoles().Where(rn =>
rn != "Administrator" && rn != "Special"));
Code in View:
@Html.DropDownList("roleName", ViewBag.roleName as SelectList, "Select")
Reply
Answers (
3
)
Server.Transfer and Response.Redirect
Cookies