开发者

VB.Net Late binding operations cannot be converted to an expression tree

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)%>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜