开发者

using Eval in vb.net

hiii everyone....

i have small problem with my code in vb.net that i want to use (Eval) in my project

so i write this code :

<asp:Label ID="Label1" runat="server"
 Text='<%#Eval("PAG_PAGES") == null ? "" : ((Pos开发者_运维知识库tAgenciesModel.PAG_PAGES)(Eval("PAG_PAGES"))).PAGE_TITLE_AR %>' />

and this code i used in my C# project .... all want to show the (Label1) in inside my GridView....

("PAG_PAGES") is the name of table..

PostAgenciesModel is the edmx...

PAGE_TITLE_AR is the colum in ("PAG_PAGES") that i want to show it

can anyone help plzzz

thanxx


The issue is that you are using C# features in a VB.NET web application.

The null keyword and the ?: and == operators are C# constructs

In VB.NET, null is Nothing, == is IS and ?: is the IIf function.


<%# If(Eval("PAG_PAGES") Is Nothing, 
        "", 
        DirectCast(Eval("PAG_PAGES"), PostAgenciesModel.PAG_PAGES).PAGE_TITLE_AR) %>

Elaborating on what Oded wrote:

expr == null  --->  expr Is Nothing
a ? b : c     --->  If(a, b, c)
(Type)expr    --->  DirectCast(expr, Type)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜