Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Asp.Net MVC 5 VB Error : " error BC36604: Late binding operations cannot be converted to an expression tree"

Posted on 2014-02-07
5
Medium Priority
?
740 Views
Last Modified: 2016-02-10
So I'm trying to pass data from a database into a drop down list on a site I'm making for an internship project. I have the LINQ query working and everything, I just don't get what the error is caused by or how to fix it. Any help would be appreciated.

Here is the code with the query from my controller for the page
Public Function gasrevperyearDD() As IEnumerable(Of SelectListItem)

            Dim List As New List(Of SelectListItem)
            List.Add(New SelectListItem With {.Text = "Select a Year", .Value = 0}) ' Adds first value as "Select a Year"
            Dim valQ = From y In db.gasrevperyears _
                      Select y.year, y.ID _
                      Order By year

            For Each k In valQ
                List.Add(New SelectListItem With {.Text = k.year, .Value = k.ID})
            Next
            gasrevperyearDD = List
        End Function

Open in new window



Here is my code from the view

@Html.DropDownListFor(Function(m) m.gasrevperyear, DirectCast (ViewData("gasrevperyearDD"), IEnumerable(Of SelectListItem)))

Open in new window

0
Comment
Question by:shanker702
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1500 total points
ID: 39843469
Can you show your page directive from the top of razor page?
0
 

Author Comment

by:shanker702
ID: 39843670
I don't have one I think, would it be at the top of the view file for the page?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39844086
Yes
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39844111
What does the assignment to gasrevperyear look like?
0
 

Author Closing Comment

by:shanker702
ID: 39848894
Got me in the right direction and I figured it out. Thanks.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question