zoukankan      html  css  js  c++  java
  • DataList在无数据记录时显示类似GridView空模板(EmptyDataTemplate)

    在FooterTemplate加个Label并根据repeater.Items.Count判断是否有记录。HTML代码:

    <FooterTemplate>
           
    <asp:Label ID="lblEmpty" Text="No data recprd exist !" runat="server"  

    Visible='<%#bool.Parse((DataList1.Items.Count==0).ToString())%>'></asp:Label> 
    </FooterTemplate> 

     Sample:

    其中: <a href='<%#Eval("ID","DeviceDetail.aspx?DeviceID={0}") %>'>是根据参数超链接到另一个页面。

             <img alt="" width="120px" src='<%#Eval("DevicePicture") %>' /><br />是读取数据库中的图片地址,并显示相应图片。

    HTML Source
     <asp:DataList ID="dlDevice" runat="server" RepeatColumns="5" RepeatDirection="Horizontal">
    <FooterTemplate>
    <div style="text-align: center; color: Red; font-weight: bold; padding-left:10px;">
    <asp:Label ID="lblEmpty" Text="No data record exist ..." runat="server" Visible='<%#bool.Parse((dlDevice.Items.Count==0).ToString())%>'></asp:Label>
    </div>
    </FooterTemplate>
    <ItemTemplate>
    <table style="margin-left: 20px; margin-top: 10px; padding: 20px; text-align: center;border: 1px solid #007795;">
    <tr>
    <td>
    <a href='<%#Eval("ID","DeviceDetail.aspx?DeviceID={0}") %>'> <img alt="" width="120px" src='<%#Eval("DevicePicture") %>' /><br />
    <span><%#Eval("DeviceName") %></span> </a>
    </td>
    </tr>
    </table>
    </ItemTemplate>
    </asp:DataList>

    左侧导航栏代码

    Be the change you want to see in the world.
  • 相关阅读:
    Servlet入门
    序列化
    ConcurrentHashMap红黑树的实现
    ConcurrentHashMap1.7和1.8的源码分析比较
    TCP/IP中的传输层协议TCP、UDP
    Java内存模型和ConcurrentHashMap 1.7源码分析
    JAVA研发面试题
    面试题(Python)
    初识Python
    Python解释器安装与环境变量添加
  • 原文地址:https://www.cnblogs.com/eva_2010/p/2342200.html
Copyright © 2011-2022 走看看