复制代码 代码如下:
/// <summary>
/// 自定义Repeater 支持EmptyDataTemplate
/// 作者: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);
}
}
}
}
新闻热点
疑难解答
图片精选