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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -