c# - There is no ViewData item of type -
good morning, i'm beginner language vb.net , asp.net , i'm getting exception , want know should define viewdata item...
the exception:
there no viewdata item of type "ienumerable <selectlistitem>" key "typeid."
the line of code exception refers :
<label>type: @html.dropdownlist("typeid", directcast(viewbag.type, ienumerable(of selectlistitem)), new { key.id = "typeid" })</label>
in controller certainly, before calling view. here, have viewbag.type, seems never defined property.
before calling view in controller, add line set viewbag.type
something :
viewbag.type = new list<selectlistitem>() ...
sorry, c#, able convert vb (i don't remember how generics work)
edit:
vb version :
viewbag.type = new list(of selectlistitem)()
thanks @dominickexel
Comments
Post a Comment