<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Adding an empty data template to the repeater control</title>
	<link>http://www.flixon.com/2007/09/26/8/</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Thu, 20 Nov 2008 20:36:44 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: admin</title>
		<link>http://www.flixon.com/2007/09/26/8/#comment-22</link>
		<author>admin</author>
		<pubDate>Tue, 30 Oct 2007 09:31:48 +0000</pubDate>
		<guid>http://www.flixon.com/2007/09/26/8/#comment-22</guid>
		<description>Hi, I found my solution above does not allow me to place controls within the empty data template, therefore i eventually went for:

public class Repeater : System.Web.UI.WebControls.Repeater
{
private ITemplate _emptyDataTemplate;

[Browsable(false)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public ITemplate EmptyDataTemplate
{
    get { return _emptyDataTemplate; }
    set { _emptyDataTemplate = value; }
}

protected override void OnItemCreated(RepeaterItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Footer &#038;&#038; this.Items.Count == 0)
    {
	// If an empty data template has been provided then display it
	if (this.EmptyDataTemplate != null)
	{
	    // Hide the header
	    this.Controls.Clear();

	    // Display the empty data template
	    Control templateContainer = new Control();
	    this.EmptyDataTemplate.InstantiateIn(templateContainer);
	    this.Controls.Add(templateContainer);

	    // Now hide the footer
	    e.Item.Visible = false;
	}
    }
    else
	base.OnItemCreated(e);
}
}

It does mean that your repeater has to have a footertemplate.</description>
		<content:encoded><![CDATA[<p>Hi, I found my solution above does not allow me to place controls within the empty data template, therefore i eventually went for:</p>
<p>public class Repeater : System.Web.UI.WebControls.Repeater<br />
{<br />
private ITemplate _emptyDataTemplate;</p>
<p>[Browsable(false)]<br />
[PersistenceMode(PersistenceMode.InnerProperty)]<br />
public ITemplate EmptyDataTemplate<br />
{<br />
    get { return _emptyDataTemplate; }<br />
    set { _emptyDataTemplate = value; }<br />
}</p>
<p>protected override void OnItemCreated(RepeaterItemEventArgs e)<br />
{<br />
    if (e.Item.ItemType == ListItemType.Footer &#038;&#038; this.Items.Count == 0)<br />
    {<br />
	// If an empty data template has been provided then display it<br />
	if (this.EmptyDataTemplate != null)<br />
	{<br />
	    // Hide the header<br />
	    this.Controls.Clear();</p>
<p>	    // Display the empty data template<br />
	    Control templateContainer = new Control();<br />
	    this.EmptyDataTemplate.InstantiateIn(templateContainer);<br />
	    this.Controls.Add(templateContainer);</p>
<p>	    // Now hide the footer<br />
	    e.Item.Visible = false;<br />
	}<br />
    }<br />
    else<br />
	base.OnItemCreated(e);<br />
}<br />
}</p>
<p>It does mean that your repeater has to have a footertemplate.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gnilly ASP.NET Developer Notes</title>
		<link>http://www.flixon.com/2007/09/26/8/#comment-21</link>
		<author>Gnilly ASP.NET Developer Notes</author>
		<pubDate>Fri, 26 Oct 2007 21:08:53 +0000</pubDate>
		<guid>http://www.flixon.com/2007/09/26/8/#comment-21</guid>
		<description>&lt;strong&gt;EmptyRepeater - Repeater with Empty Template...&lt;/strong&gt;

...</description>
		<content:encoded><![CDATA[<p><strong>EmptyRepeater - Repeater with Empty Template&#8230;</strong></p>
<p>&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
