Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.NET
<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>
Posted
Updated 15-Sep-13 11:49am
v2

i fix it with below code
ASP.NET
<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>
 
Share this answer
 
I'm not an expert but shouldn't it be:

C#
<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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900