Prev | Current Page 789 | Next

Rob Cameron and Dale Michalk

"Pro ASP.NET 3.5 Server Controls and AJAX Components"


If you look at CreateBlankControlHierarchy, you see that it looks for the HeaderTemplate
and FooterTemplate templates and creates a ResultItem control to wrap them using the
CreateResultItem helper method. We examine CreateResultItem in just a bit, but here is
CreateBlankControlHierarchy:
private void CreateBlankControlHierarchy()
{
if (HeaderTemplate != null)
{
ResultItem headerItem = CreateResultItem(-1, ResultItemType.Header, false,
null);
items.Add(headerItem);
}
if (FooterTemplate != null)
{
ResultItem footer = CreateResultItem(-1, ResultItemType.Footer,
false, null);
items.Add(footer);
}
}
It adds the ResultItem control to an internal ArrayList collection. This is a publicly reachable
collection that is exposed via a top-level Items property on Result, as shown in the following
code. Notice that we didn??™t add the ResultItem controls to the Controls collection of Result in
CreateBlankControlHierarchy. This is handled by CreateResultItem, along with other things
such as data binding and raising item-related events.
private Collection items = new Collection();
public Collection Items
{
get
{
return items ;
}
}
The items collection takes advantage of the List generic type removing the need to create
a custom strongly typed collection.


Pages:
777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801