Set Visible attribute in the node of HTML for ASPX

来源:互联网 发布:如何写淘宝试用报告 编辑:程序博客网 时间:2024/05/29 00:31

There are two columns in this GridView. The second one shows the status as a flag.

The type of value in the database is integer (or bit). The value of field IsConfigured set to 0 or 1

For the yesImage, you can use this: Visible='<%# Eval("IsConfigured")%>'

But, when I try to use Visible='<%# Not Eval("IsConfigured")%>' for the second image, unfortunately it does work.

Source Code:

<asp:TemplateField SortExpression="IsConfigured" >

<ItemTemplate>

<asp:Image ID="yesImage" runat="server" Visible='<%# CType(Eval("IsConfigured"),Boolean)%>'/>

      <asp:Image ID="noImage" runat="server" Visible='<%# Not CType( Eval("IsConfigured"), Boolean) %>' />

</ItemTemplate>

</asp:TemplateField>