title: Storing and Retrieving Values in Arraylist in ASP.NET
body: <p>I am trying to store values in an Arraylist on button click event and trying to retrieve it on another button click. But somehow the Arraylist remains empty and I am getting no output. Plz Help!!</p>
  
  <pre><code>      ArrayList al = new ArrayList();
  protected void btn1_Click(object sender, EventArgs e)
  {
      Class1 cl1 = new Class1();
      cl1.name = txt1.Text;
      cl1.course = txt2.Text;
  
      al.Add(cl1);
  }
  
  protected void btn2_Click(object sender, EventArgs e)
  {
      for (int i = 0; i &lt; al.Count; i++)
      {
          Class1 cl = (Class1)al[i];
          Response.Write(cl.name);
          Response.Write(cl.course);
      }
  }
  </code></pre>