views:

50

answers:

1
<asp:TemplateField HeaderText="Audio">
    <ItemTemplate>
        <asp:Image ID="playImage" runat="server"
            ImageUrl="~/images/nextpg.gif"
            Visible='<%# (Eval("available")=="Y") ? true : false %>' />
    </ItemTemplate>
</asp:TemplateField>

In my query I am returning the "available" column which is populated with a letter of Y or N. For some reason the evaluation of this expression is never true. If I change it to != instead of == it will always be true. That leads me to believe the Eval("available")=="Y" is simply not evaluating as expected.

A: 

After much messing around, this finally worked:

<%# ((String)Eval("available")).Equals("Y") ? true : false %>

The issue seems to be that you can't use == but instead you must use the String.Equals() method. I'm not sure why but that's just the way it is.

Joe Philllips

related questions