\' /> Error: Compiler Error Message: CS1525: In开发者_JAVA百科valid expression term \'," />
开发者

Asp.Net(C#) inline coding Eval if statement problem

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜