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
Abhilash J A
533
2.4k
598.2k
error - passing array value to viewdata MVC5
Jan 11 2017 9:06 AM
Hello everyone,
This is the Controller,
string
[] arryvalidvalue =
new
string
[] {
"Red"
,
"Black"
,
"White"
};
List<SelectListItem> listValidValies =
new
List<SelectListItem>();
foreach
(var item
in
arryvalidvalue)
{
listValidValies.Add(
new
SelectListItem { Text = item, Value = item.ToString() });
}
ViewData[
"arryvalidvalue"
] = listValidValies;
and view,
<
tr
>
<
td
>
@Html.TextBox(item.AttributeName)
</
td
>
<
td
>
@Html.DropDownList("", ViewData["arryvalidvalue"] as List
<
SelectListItem
>
, "Select", new {
size
=
item
.AttributeMaxLength })
</
td
>
</
tr
>
error occured:
"
An exception of type 'System.ArgumentException' occurred in System.Web.Mvc.dll but was not handled in user code
Additional information: Value cannot be null or empty.
"
How can I solve this?
Reply
Answers (
6
)
Stored Procedure Parameters
I am getting error while returning data to view from action