检查此源代码的错误 [英] Check the error for this source code

查看:70
本文介绍了检查此源代码的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请检查此代码,我需要在源代码中声明if和else,但是它显示错误,如无效表达式项if

Please check this code, I need to declare this if and else in source code but it shown error like invalid expression term if

<%#if(Eval("a_comment_counter")>0){%> <a href="a_comments.aspx?a_id=<%# Eval("a_id")%>"><%# Eval("a_comment_counter")%>
        comments</a> | <%} else {%><i>0 comments</i>


请任何人帮我.
在此先感谢

如果我这样声明条件但也有同样的问题



please any one help me.
Thanks in advance

if i declare condition like this but also the same problem


<%#if(Eval("a_comment_counter")!=null){%> <a href="a_comments.aspx?a_id=<%# Eval("a_id")%>"><%# Eval("a_comment_counter")%>
        comments</a> | <%} else {%><i>0 comments</i>

推荐答案

您不能在Eval函数中使用if-else构造.相反,您可以在此链接中使用语法,该语法也与if-else一样.您可以从这里获得解决方案.简单明了,简单明了.解决方案 [ ^ ]
You cant use if-else construct in Eval function. Instead, you can use the syntax in this link which also acts as it were if-else. You can get your solution from here. It is Straight forward, clear and easy.Solution[^]


如果查看文档,则会看到DataBinder.Eval返回一个Object.您的if语句试图比较一个Object和一个无法解析的整数.尝试将左侧转换为整数或将右侧转换为字符串.
If you look at the documentation you see DataBinder.Eval returns an Object. Your if statement is trying to compare an Object and an integer, which can''t be resolved. Try casting the left side to an integer or making the right side a string.


在if之前先删除#,然后再尝试.或尝试一下,-
remove # before if and then try. Or try like,-
<%if(%><%#Eval("a_comment_counter")%><%>0){


这篇关于检查此源代码的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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