1 using System;
2 using System.Collections;
3 using System.Data;
4 using System.Web.UI.WebControls;
5 using System.Xml.XPath;
6 
7 namespace test
8 {
9   public class SimplePage : System.Web.UI.Page
10   {
11     protected XmlDataSource XmlDataSource;
12 
SimplePage()13     public SimplePage()
14     {
15       RepeaterTest t = new RepeaterTest ();
16 
17       Controls.Add (t);
18 
19 #if true
20       t.DataSourceID = "XmlDataSource";
21 #else
22       t.DataSource = XmlDataSource;
23 #endif
24     }
25   }
26 
27   public class RepeaterTest : Repeater {
DataBind()28   	public override void DataBind ()
29   	{
30 		Page.Response.Write (String.Format ("<pre>In DataBind, from {0}</pre>", Environment.StackTrace));
31 		base.DataBind ();
32 	}
33 
CreateControlHierarchy(bool useDataSource)34   	protected override void CreateControlHierarchy (bool useDataSource) {
35 		Page.Response.Write (String.Format ("<pre>In CreateControlHierarchy({0}), from {1}</pre>", useDataSource, Environment.StackTrace));
36 		base.CreateControlHierarchy (useDataSource);
37 	}
38 
OnInit(EventArgs e)39   	protected override void OnInit (EventArgs e) {
40 		Page.Response.Write (String.Format ("<pre>In OnInit, from {0}</pre>", Environment.StackTrace));
41 		base.OnInit (e);
42 	}
43 
GetData()44   	protected override IEnumerable GetData () {
45 		Page.Response.Write (String.Format ("<pre>In GetData, from {0}</pre>", Environment.StackTrace));
46 
47 		IEnumerable data = base.GetData();
48 
49 		IEnumerator e = data.GetEnumerator();
50 
51 		while (e.MoveNext()) {
52 			Page.Response.Write (String.Format (" + {0}<br/>", e.Current));
53 			IXPathNavigable desc = (IXPathNavigable)e.Current;
54 			Page.Response.Write (String.Format ("+ + navigator = {0}<br/>", desc.CreateNavigator().GetType()));
55 		}
56 
57 		return data;
58 	}
59 #if false
60     /* can't do this one, as it is invoked in the setter for DataSourceID. */
61 
OnDataPropertyChanged()62   	protected override void OnDataPropertyChanged () {
63 		if (Page != null)
64 			Page.Response.Write (String.Format ("<pre>In OnDataPropertyChanged, from {0}</pre>", Environment.StackTrace));
65 		base.OnDataPropertyChanged ();
66 	}
67 #endif
OnDataSourceViewChanged(object sender, EventArgs e)68   	protected override void OnDataSourceViewChanged (object sender, EventArgs e) {
69 		Page.Response.Write (String.Format ("<pre>In OnDataSourceViewChanged, from {0}</pre>", Environment.StackTrace));
70 		base.OnDataSourceViewChanged (sender, e);
71 	}
72 
CreateItem(int itemIndex, ListItemType itemType)73     protected override RepeaterItem CreateItem (int itemIndex, ListItemType itemType) {
74       Page.Response.Write (String.Format ("<pre>In CreateItem, from {0}</pre>", Environment.StackTrace));
75       return base.CreateItem (itemIndex, itemType);
76     }
77 
InitializeItem(RepeaterItem item)78     protected override void InitializeItem (RepeaterItem item) {
79       Page.Response.Write (String.Format ("<pre>In InitializeItem, from {0}</pre>", Environment.StackTrace));
80       base.InitializeItem (item);
81     }
82   }
83 }
84