Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to Show a message when DataList is Empty

I'm using DataList to show records on Client Site of my web page. I need to show a message when my DataList is empty. Is there a property of Datalist? How to show that message?

like image 726
leonyx Avatar asked May 03 '10 06:05

leonyx


Video Answer


1 Answers

EmptyDataText property is not supported by DataList yet. But you can achieve almost same functionality using the following trick:

<FooterTemplate>
    <asp:Label Visible='<%#bool.Parse((DataList1.Items.Count==0).ToString())%>' 
               runat="server" ID="lblNoRecord" Text="No Record Found!"></asp:Label>
</FooterTemplate>

That is creating a Label in Footer of DataList, and make it visible only of DataList record count is 0.

like image 170
Tayyab Ali Avatar answered Oct 12 '22 23:10

Tayyab Ali