Same as in Gridview, we have EmptyDataTemplate in Listview to display some static message whenever there is no data to display for Listview.
You have to place the EmptyDataTemplate after ItemTemplate and inside the EmptyDataTemplate you can place some static message as shown below.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ListView ID="lv1" runat="server">
<LayoutTemplate>
<asp:Placeholder id="itemPlaceholder"runat="server"/>
</LayoutTemplate>
<ItemTemplate>
This is place holder for Data
</ItemTemplate>
<EmptyDataTemplate>
No Data Found
</EmptyDataTemplate>
</asp:ListView>
<br/>
<asp:Button ID="btn" runat="server" Text="Click" onclick="btn_Click"/>
</div>
</form>
</body>
</html>
Whenever user clicks the button, bind the null data source to the Listview to display the message in EmptyDataTemplate as shown below.
protected void btn_Click(object sender, EventArgs e)
{
lv1.DataSource = null;
lv1.DataBind();
}
The out put displays the message as "No Data Found" as mentioned in EmptyDataTemplate.