Home The ViewData item that has the key 'Catagory_id' is of type 'System.Int32' but must be of type 'IEnumerable<SelectListItem>'
Reply: 0

The ViewData item that has the key 'Catagory_id' is of type 'System.Int32' but must be of type 'IEnumerable<SelectListItem>'

user7564
1#
user7564 Published in September 21, 2018, 8:03 am

This question already has an answer here:

  • The ViewData item that has the key 'XXX' is of type 'System.Int32' but must be of type 'IEnumerable<SelectListItem>' 1 answer

this is the table that have a relation with Category_id as you can see

and im using entity framework so you can see the class

this is my edit (get)controller

when i run my application it gives me this error on dropdownlist

i want to retrieve category_name data from the catalog_categories to show which product belongs to which category. need help

share|improve this question

marked as duplicate by Hackerman, Stephen Muecke asp.net-mvc StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var $hover = $(this).addClass('hover-bound'), $msg = $hover.siblings('.dupe-hammer-message'); $hover.hover( function() { $hover.showInfoMessage('', { messageElement: $msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Feb 13 at 21:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Try following: <%= Html.DropDownList("Category_id", (IEnumerable<SelectListItem>)ViewData["Category_id"]) %> ? – FaizanRabbani Feb 13 at 18:19
  • thanks for your reply faizanrabbani but i have tried that before it still giving me error – faseeh Feb 13 at 18:33

1 Answer 1

active oldest votes
up vote 1 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.300401 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO