在Bind / Eval中使用If语句 [英] using If statement in Bind/Eval
本文介绍了在Bind / Eval中使用If语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿伙计们我想使用Eval with Condition但我有以下错误
编译器错误消息:CS0131:左边 - 作业的一方必须是变量,属性或索引器
i使用以下代码
< asp:ListView ID = lsvmain runat = server >
< ItemTemplate >
< ; div class = span8 >
< h5 >
< asp:Image ID = uimg runat = server CssClass = img-polaroid 宽度 = 44px ImageUrl =' <% #Eval( imgsrc)%>' / >
< asp:标签 ID = lblTitle runat = server 文字 =' <% #Eval( Title )%>' > < / asp:标签 >
< / h5 >
< / div >
< < span class =code-leadattribute> div class = span4 >
< asp:Label ID = Label1 runat = server 文本 =' <% #Eval( StReply)= true ? yes: no%>' > < / asp:标签 >
< / div >
< hr / >
< / ItemTemplate >
< / asp:ListView >
解决方案
我使用下面的代码修复它
< asp:label id = Label1 runat < span class =code-keyword> = server text = <%#(Eval( StReply)。ToString()== True)? < i class = icon-comments>< / i>پاسخدادهشده: < i class = icon-comment-alt>< / i>پاسخدادهنشده%> xmlns:asp = #unknown > < / asp:label >
我不是专家,但不应该是:
< asp:label id = Label1 runat = < span class =code-string> server text = <%#Eval(< /跨度>链霉素ly )== true? 是 : no %> xmlns:asp = #unknown >
< / asp:label >
注意==而不是=,==是比较,=是作业。
hey guys i want to use Eval with Condition but i have below error
Compiler Error Message: CS0131: The left-hand side of an assignment must be a variable, property or indexer
i use below code
<asp:ListView ID="lsvmain" runat="server">
<ItemTemplate>
<div class="span8">
<h5>
<asp:Image ID="uimg" runat="server" CssClass="img-polaroid" Width="44px" ImageUrl='<%# Eval("imgsrc") %>' />
<asp:Label ID="lblTitle" runat="server" Text='<%# Eval("Title") %>'></asp:Label>
</h5>
</div>
<div class="span4">
<asp:Label ID="Label1" runat="server" Text='<%# Eval("StReply") = true ? "yes" : "no" %>'></asp:Label>
</div>
<hr />
</ItemTemplate>
</asp:ListView>
解决方案
i fix it with below code
<asp:label id="Label1" runat="server" text="<%# (Eval("StReply").ToString() == "True") ? " <i class=icon-comments></i> پاسخ داده شده" : " <i class=icon-comment-alt></i> پاسخ داده نشده" %>" xmlns:asp="#unknown"></asp:label>
I'm not an expert but shouldn't it be:
<asp:label id="Label1" runat="server" text="<%# Eval("StReply") == true ? "yes" : "no" %>" xmlns:asp="#unknown"> </asp:label>
Notice the == instead of the =, == is a comparison, = is an assignment.
这篇关于在Bind / Eval中使用If语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文