Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
emptydatatext use in datalist like gridview?
Posted
Updated 7-May-16 14:26pm

This is not a question but since I think I know what you are asking, only because I did this recently, I'll give you the code.

DataList does not have an EmptyDataText property but you can do it using a FooterTemplate. For example:

ASP.NET
<footertemplate>
   <asp:label visible="<%#bool.Parse((dl1.Items.Count==0).ToString())%>" xmlns:asp="#unknown">
      runat="server" ID="lblNoRecord" Text="None"></asp:label>
</footertemplate>


This will make the footer template visible or not if there are any records.
 
Share this answer
 
In Footer Template:

VB
 <asp:label id="Mensaje" runat="server" visible="<%# If(DataList1.Items.Count = 0, True, False)%>;" text="PRODUCTO NO ENCONTRADO">
</asp:label>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900