problem with ArrayList

Feb 14 2006 7:15 AM
Hi,

I have a little problem with ArrayList that make me crazy,
I have a usual Web Application that contains two Buttons,

When i click on Button1 it would add an object to MyArrayList and Button2 Shows the Objects.
but MyArrayList.Count is Zero allways.

here is my code:
public partial class DoFeed : System.Web.UI.Page
{
     private ArrayList TheItems = new ArrayList();
    
     protected void Page_Load(object sender, EventArgs e){  }

     protected void Button1_Click(object sender, EventArgs e) 
    {             
        OneItem Item = new OneItem();
        Item.Title = TitleTXT.Text;
        Item.Link = LinkTXT.Text;

        TheItems.Add(Item);
    }
    
    protected void Button2_Click(object sender, EventArgs e)
    {
        int m = TheItems.Count; //it is zero allways
        for(int i=0; i<TheItems.Count i++)
         .......
    }
}

Answers (4)