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
676 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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

840 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