Eval中的三元运算符问题 [英] Problem with ternary operator in Eval
本文介绍了Eval中的三元运算符问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!
我已经在gridview中采取了一个项目模板.我已将其绑定到值为0或1的列名状态.现在,我将Eval()与三元运算符结合使用,以在项目模板字段内设置标签的文本.但这总是向我显示错误条件.列具有0和1值.它的数据类型为int Plz帮我解决问题!
Hi all!!
i have taken an item template inside a gridview. I have bind it to a column name status which has values either 0 or 1. Now i am using Eval() with ternary operator to set the text of the label inside the item template field. But it''s always showing me the False condition. Column has both 0 and 1 values.it''s DataType is int Plz help Me out!!
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:Label id="lblStatus" runat="server" Text=''<%#Eval("Status")=="1"?"ClubMember":"Free User" %>''></asp:Label>
</ItemTemplate>
</asp:TemplateField>
推荐答案
尝试一下
<%#Eval("Status").ToString()=="1" ? "ClubMember" : "Free User" %>
使用评估 [
Using Eval[^]
这篇关于Eval中的三元运算符问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文