【问题标题】:displaying image in grid view column of aspx page with condition在带有条件的 aspx 页面的网格视图列中显示图像
【发布时间】:2014-07-08 12:44:15
【问题描述】:

我需要根据 gridview 列中的条件显示图像,如果 gridview 列是“已处理”,我需要显示刻度图像,否则我需要显示 x 图像..

我的aspx页面代码:

<asp:TemplateField HeaderStyle-Width="90px" ItemStyle-Width="0">
        <ItemTemplate><%#Eval("StatusName")%>//here the status name loads like Processed,Failed,..
          <br />
          <%#Eval("Comments")%>
        </ItemTemplate>

<HeaderStyle Width="90px"></HeaderStyle>

<ItemStyle Width="0px"></ItemStyle>

提前谢谢..

【问题讨论】:

    标签: c# asp.net .net image gridview


    【解决方案1】:

    有条件地为图像元素设置ImageUrl 属性,如下所示:

    例如:

    <asp:TemplateField HeaderStyle-Width="90px" ItemStyle-Width="0">
      <ItemTemplate>
        <%#Eval("StatusName")%>//here the status name loads like Processed,Failed,..
        <asp:Image runat="server"
           ImageUrl='<%# 
             (Eval("StatusName").Equals("Processed") ? "tick.png" : "cross.png") 
           %>' />
        <br />
        <%#Eval("Comments")%>
      </ItemTemplate>
    </asp:TemplateField>
    

    【讨论】:

      猜你喜欢
      • 2021-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多