Tuesday, May 15, 2012

Empty dataset template for DataList control

There is no Empty dataset Template for the DataList control. To display a message in the DataList control if your dataset is empty, define a HeaderTemplate and set the visibility based upon the item count as shown below:
 
<asp:DataList runat="server" id="DataList1" DataSourceID="spDataSource1">
<HeaderTemplate>
<span style="font-style:italic;color:#181818">
<asp:Label ID="lblEmpty" Text="No Events" runat="server" Visible='<%# DataList1.Items.Count==0 %>'/>
</span>
</HeaderTemplate>
<ItemTemplate>
<p>
...
</p>
</ItemTemplate>
</asp:DataList>

No comments:

Post a Comment