List created in OnInit not persisting
<p>I having a problem maintaining a list of strings. The list is instantiated in OnInit and set as the data source for a <code>GridView</code>. (The basic idea is that the user enters something in the text box, and it appears in the <code>GridView</code>, as many times as they want.)</p>

<p>It works just fine for the first entry, whatever the user enters shows up in the <code>GridView</code>, pretty as can be. However, on following entries, any previously entered values disappear - <code>OnInit</code> is executed again, the <code>List&lt;string&gt;</code> is re-instantiated, and the previous values are over-written. I tried moving the <code>OnInit</code> logic into <code>OnPreInit</code> but just got a Null Reference Exception on the list.</p>

<p>Here's a contrived example of what I'm trying to do:</p>

<p>I have a <code>TextBox</code>, a <code>Button</code> and a <code>Gridview</code>:</p>

<pre><code>&lt;asp:TextBox ID="TextBox1" runat="server"&gt;&lt;/asp:TextBox&gt;
&lt;asp:Button ID="Button1" runat="server" Text="Add"
     onclick="Button1_Click" /&gt;
&lt;asp:GridView ID="GridView1" runat="server"
    AutoGenerateColumns="true"&gt;&lt;/asp:GridView&gt;
</code></pre>

<p>In the code behind:</p>

<pre><code>protected override void OnInit(EventArgs e)
{
    List&lt;string&gt; gvValues = new List&lt;string&gt;();
    GridView1.DataSource = gvValues;
    GridView1.DataBind();
}

protected void Button1_Click(object sender, EventArgs e)
{
     gvValues.Add(TextBox1.Text);
     GridView1.DataBind();
}
</code></pre>

<p>I've created objects in <code>OnInit</code> in the past, and haven't had a problem with their state persisting. Obviously I'm missing something here. Someone please point out the flaw in my logic and suggest a method for achieving this functionality.</p>
