ListView EmptyDataTemplate.aspx
<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>ListView EmptyDataTemplate - how to use EmptyDataTemplate</title>
<style type="text/css">
.TableCSS
{
background-color:Gray;
width: 725px;
}
.TableHeader
{
background-color:SlateBlue;
color:Snow;
font-size:large;
font-family:Times New Roman;
height:45px;
text-align:center;
}
.ItemCSS
{
background-color:DimGray;
color:Snow;
font-family:MS Sans Serif;
font-size:medium;
font-weight:bold;
height:28px;
}
.EmptyDataCSS
{
background-color:Red;
color:White;
font-size:xx-large;
text-align:center;
height:150px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:OrangeRed; font-style:italic;">ListView Example: How To Use EmptyDataTemplate</h2>
<hr width="625" align="left" color="Orange" />
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="Select Top 0 ProductID, ProductName, UnitPrice From products Order By ProductID"
>
</asp:SqlDataSource>
<br />
<asp:ListView
ID="ListView1"
runat="server"
DataSourceID="SqlDataSource1"
DataKeyNames="ProductID"
>
<LayoutTemplate>
<table id="Table1" runat="server" class="TableCSS">
<tr id="Tr1" runat="server" class="TableHeader">
<td id="Td1" runat="server">Product ID</td>
<td id="Td2" runat="server">Product Name</td>
<td id="Td3" runat="server">Unite Price</td>
</tr>
<tr id="ItemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr class="ItemCSS">
<td>
<asp:Label
ID="Label1"
runat="server"
Text='<%# Eval("ProductID")%>'
>
</asp:Label>
</td>
<td>
<asp:Label
ID="Label2"
runat="server"
Text='<%# Eval("ProductName")%>'
>
</asp:Label>
</td>
<td>
<asp:Label
ID="Label3"
runat="server"
Text='<%# Eval("UnitPrice")%>'
>
</asp:Label>
</td>
</tr>
</ItemTemplate>
<EmptyDataTemplate>
<table class="TableCSS">
<tr class="TableHeader">
<td>Product ID</td>
<td>Product Name</td>
<td>Unite Price</td>
</tr>
<tr>
<td colspan="3" class="EmptyDataCSS">
sorry ! no data found
</td>
</tr>
</table>
</EmptyDataTemplate>
</asp:ListView>
</div>
</form>
</body>
</html>
No comments:
Post a Comment