<%# Eval("NAME").ToString() == "Edit" ? %> ' />
Error: Compiler Error Message: CS1525: In开发者_JAVA百科valid expression term ',
How to make please help me?
Thank you all;
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 %>' />
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 %>' />
精彩评论