2

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

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

How to make please help me?

Thank you all;

2 Answers 2

4

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 %>' />
Sign up to request clarification or add additional context in comments.

2 Comments

can u tick question as answered? Thanks
I just went to vote for this and found out that I've looked it up before and voted on it last year. Lol. Thanks again! Wish I could remember all the things I've ever looked up.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.