VB.Net后期绑定操作不能转换为前pression树 [英] VB.Net Late binding operations cannot be converted to an expression tree

查看:139
本文介绍了VB.Net后期绑定操作不能转换为前pression树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了一些VB.Net后期绑定操作并收到此错误:


  

后期绑定操作不能转换为前pression树。


我已经在这里搜查,只能找到SQL获取数据code解决方案,而不是我的问题。

在我所有的 x.NAME 行!?

林新的这个所以任何人说我为什么我得到这个错误。

 < D​​IV> Navn:LT;%:Html.EditorFor(功能(X)x.Name)%GT;< / DIV>< H3>住址< / H3 GT&;< D​​IV> Linje 1:<%:Html.EditorFor(功能(X)x.Line1)%GT;< / DIV>
< D​​IV> Linje 2:<%:Html.EditorFor(功能(X)x.Line2)%GT;< / DIV>
< D​​IV> Linje 3:LT;%:Html.EditorFor(功能(X)x.Line3)%GT;< / DIV>
< D​​IV> Postnr:LT;%:Html.EditorFor(功能(X)x.Zip)%GT;< / DIV>
< D​​IV>按:其中,%:Html.EditorFor(功能(X)x.City)%GT;< / DIV>
< D​​IV> Landsdel:LT;%:Html.EditorFor(功能(X)x.Country)%GT;< / DIV>< H3> Tilvalg< / H3 GT&;
<标签>
    <%:Html.EditorFor(功能(X)x.GiftWrap)%GT;
    狄氏瓦尔SKAL我Gaveindpakning。
< /标签>


解决方案

的问题是,你要使用强类型的辅助,比如 Html.EditorFor ,而你的观点不是强类型的一类。所以,你需要指明模型类型 @Page 定义:

 <%@页
    LANGUAGE =VB
    的MasterPageFile =〜/查看/共享/的Site.Master
    继承=System.Web.Mvc.ViewPage(中YourApplication.YourModelClass)%GT;

注意如何认为现在是强类型的模型类 YourApplication.YourModelClass 。现在,您可以安全地使用这些辅助方法:

 <%:Html.EditorFor(功能(X)x.Name)%GT;

I'm getting some VB.Net Late binding operations and getting this error:

Late binding operations cannot be converted to an expression tree.

I've searched here and can only find solutions to the SQL get data code, not to my problem.

At all my x.NAME lines !?

Im new to this so can anyone say me why i get this error..

<div>Navn: <%: Html.EditorFor(Function(x) x.Name)%></div>   

<h3>Adresse</h3>   

<div>Linje 1: <%: Html.EditorFor(Function(x) x.Line1)%></div>   
<div>Linje 2: <%: Html.EditorFor(Function(x) x.Line2)%></div>   
<div>Linje 3: <%: Html.EditorFor(Function(x) x.Line3)%></div>   
<div>Postnr: <%: Html.EditorFor(Function(x) x.Zip)%></div>   
<div>By: <%: Html.EditorFor(Function(x) x.City)%></div>   
<div>Landsdel: <%: Html.EditorFor(Function(x) x.Country)%></div>   

<h3>Tilvalg</h3>   
<label>   
    <%: Html.EditorFor(Function(x) x.GiftWrap)%>   
    Disse vare skal i Gaveindpakning.   
</label>   

解决方案

The problem is that you are trying to use strongly typed helpers like Html.EditorFor while your view is not strongly typed to a class. So you need to indicate the model type in the @Page definition:

<%@ Page 
    Language="VB" 
    MasterPageFile="~/Views/Shared/Site.Master" 
    Inherits="System.Web.Mvc.ViewPage(Of YourApplication.YourModelClass)" %>

Notice how the view is now strongly typed to the model class YourApplication.YourModelClass. Now you can safely use those helper methods:

<%: Html.EditorFor(Function(x) x.Name)%>

这篇关于VB.Net后期绑定操作不能转换为前pression树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆