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
719 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 500 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

617 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