简体   繁体   English

在vb.net中使用Eval

[英]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 我在vb.net中的代码中有一个小问题,我想在项目中使用(Eval)

so i write this code : 所以我写这段代码:

<asp:Label ID="Label1" runat="server"
 Text='<%#Eval("PAG_PAGES") == null ? "" : ((PostAgenciesModel.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.... 而我在C#项目中使用的这段代码....所有人都想在GridView中显示(Label1)。

("PAG_PAGES") is the name of table.. ("PAG_PAGES")是表的名称。

PostAgenciesModel is the edmx ... PostAgenciesModeledmx ...

PAGE_TITLE_AR is the colum in ("PAG_PAGES") that i want to show it PAGE_TITLE_AR是我要向其显示的("PAG_PAGES")中的列

can anyone help plzzz 谁能帮忙

thanxx thanxx

The issue is that you are using C# features in a VB.NET web application. 问题是您正在VB.NET Web应用程序中使用C#功能。

The null keyword and the ?: and == operators are C# constructs null关键字以及?:==运算符是C#构造

In VB.NET, null is Nothing , == is IS and ?: is the IIf function. 在VB.NET中, nullNothing==IS?:IIf函数。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM