在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 />是读取数据库中的图片地址,并显示相应图片。

DataList在无数据记录时显示类似GridView空模板(EmptyDataTemplate)

DataList在无数据记录时显示类似GridView空模板(EmptyDataTemplate)

 

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>

 

左侧导航栏代码

相关文章:

  • 2022-12-23
  • 2021-10-27
  • 2021-10-22
  • 2021-08-12
  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2021-10-26
猜你喜欢
  • 2021-12-19
  • 2021-09-16
  • 2021-05-25
  • 2022-03-08
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案