Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
6
Answers
error - passing array value to viewdata MVC5
Mani Kandan
7y
245
1
Reply
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?
Post
Reset
Cancel
Answers (
6
)
Next Recommended Forum
Stored Procedure Parameters
I am getting error while returning data to view from action