'/ "> Error: Compiler error message...">

Asp.Net (C #) inline encoding Eval if instruction problem

<% # Eval ("NAME"). ToString () == "Change"? %> '/ ">

Error: Compiler error message: CS1525: Invalid expression term ',

How to do please help me?

Thanks everyone,

+2


a source to share


2 answers


This will do:



<asp:ImageButton ID="imgEdit" runat="server" ImageUrl="../icons/icoedit.png" CommandName="Edit" Visible='<%# Convert.ToBoolean(Eval("NAME").ToString() == "Edit") %>' CommandArgument='<%# Container.DataItemIndex %>' />

      

+4


a source


What? at the end it looks like you are going for a ternary operator, but you haven't finished it yet.

Personally, in this situation, I like to use a visible property, for example:

<asp:ImageButton ID="imgEdit" runat="server" ImageUrl="../icons/icoedit.png" 
CommandName="Edit" Visible='<%# Eval("NAME").ToString() == "Edit" %>' 
CommandArgument='<%# Container.DataItemIndex %>' />

      



Or if you want the opposite

<asp:ImageButton ID="imgEdit" runat="server" ImageUrl="../icons/icoedit.png" 
CommandName="Edit" Visible='<%# Eval("NAME").ToString() != "Edit" %>' 
CommandArgument='<%# Container.DataItemIndex %>' />

      

0


a source







All Articles