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
654 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 74

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now