DataTable that can be accessed from Repeater.ItemDataBound
<p>I'm new to ASP.Net, C#, and OOP in general, and I'm trying to get into the right paradigm about classes, objects, methods, etc.</p>

<p>I would like to access a <code>DataTable</code> from the Repeater.ItemDataBound event. Where would I create the <code>DataTable</code> so the method can access it? I don't want the DataTable created everytime ItemDataBound is called, just once. Would that be a separate class, or another method in the same class, or something else? </p>

<p>I want to use this to set values on controls in the <code>HeaderTemplate</code> of a <code>Repeater</code>. Here is my code:</p>

<pre><code>public partial class test : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        int numPages = 3, numItems = 10;

        int[] parentRepeatCnt = Enumerable.Range(0, numPages).ToArray();
        int[] childRepeatCnt = Enumerable.Range(0, numItems).ToArray();

        ParentRepeater.DataSource = parentRepeatCnt;
        ParentRepeater.DataBind();

        foreach (int i in parentRepeatCnt)
        {
            Repeater ChildRepeater = ParentRepeater.Items[i].FindControl("ChildRepeater") as Repeater;
            ChildRepeater.DataSource = childRepeatCnt;
            ChildRepeater.DataBind();
        }
    }

    public void ChildRepeater_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Header)
        {
            Label Label1 = e.Item.FindControl("Label1") as Label;
            // access DataTable here
            Label1.Text = myDataTable.Rows[0]["item"].ToString();
        }

    }
}
</code></pre>

<p>Also, please feel free to critique my existing code. Thanks!</p>
