foreach statement does not contain a public definition for 'GetEnumerator' MVC

(1 post) (1 voice)


Reply to this Topic Start new Topic

Custom Search

  1. C_K
    C_K
    Distinguished
    Moderator
    Score: 157

    Recently I got a bug while doing some code in MVC 2.0 as follows:


    foreach statement cannot operate on variables of type 'theCollegehunt.Models.topic' because 'theCollegehunt.Models.topic' does not contain a public definition for 'GetEnumerator'

    here topic is name of table added in model theCollegehunt.Models

    I Google a lot but didn't get any solution that works.
    Finally I modified my Inherits tag in page directive to:

    System.Web.Mvc.ViewPage<IEnumerable<theCollegehunt.Models.topic>>

    from

    System.Web.Mvc.ViewPage<theCollegehunt.Models.topic>

    and it worked..!!

    Posted 5 months ago #

Post a Comment

You must log in to post.