tags:

views:

350

answers:

2

Hi all;

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

Error: Compiler Error Message: CS1525: Invalid expression term ',

How to make please help me?

Thank you all;

+2  A: 

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 %>' />
Luis
@Luis Thank you Work
Oraclee
can u tick question as answered? Thanks
Luis
A: 

Hey,

The ? on the end looks like you are going for a ternary operator but you haven't finished it off.

Personally in this situation I like to use the visible property like:

<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 %>' />
rtpHarry