The Repeater control is a data display control that allows you to customize the layout by repeatedly using the specified template for each item displayed in the list.
Compared to GridViews and DataList, Repeater is a lightweight, flexible control that consumes a lot less energy than they do. The drawback is that the function is slightly thin, especially for the binding data source without data, often to use a hidden surface version to display "Temporarily no data" information. It's too much trouble.
The Repeater control's EmptyDataTemplate template has been extended to achieve the same effect.
(VS2008) Customizing a repeater control to have a functional solution with EmptyDataTemplate template-add-New Project-"Select C # Class Library
Add a reference to the newly created class library select System.Web in the. NET tab
Copy Code code as follows:
<summary>
Custom Repeater Support EmptyDataTemplate
Author: cantops
</summary>
public class Repeater:System.Web.UI.WebControls.Repeater
{
Private ITemplate EmptyDataTemplate;
[PersistenceMode (Persistencemode.innerproperty), TemplateContainer (typeof (TemplateControl))]
Public ITemplate EmptyDataTemplate
{
get {return emptydatatemplate;}
set {emptydatatemplate = value;}
}
protected override void OnDataBinding (EventArgs e)
{
Base. OnDataBinding (e);
if (emptydatatemplate!= null)
{
if (this. Items.Count = 0)
{
Emptydatatemplate.instantiatein (this);
}
}
}
}
Then make a direct reference to the user control to use.