Well this class is so small I'll just show you all of the code at once: using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Guestbook.Engine;
namespace Guestbook
{
/// <summary>
/// Summary description for GuestbookRepeater.
/// </summary>
[ParseChildren(true)]
public class GuestbookRepeater : Repeater
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
DataSource = XmlEngine.GetGuestbookEntries();
DataBind();
}
}
}
As you can see, no magic here, just a single overridden method that sets a hard coded value as the control's DataSource
. DataBind
method is also called here.
Although there is one little piece of “magic” – the class derives from System.Web.UI.WebControls.Repeater
.
Now we're actually finished, but I'd like to show you how you can add these controls to any of your pages...
Comments