[align=left] 
   public ArrayList arl = new ArrayList();  //我在这里定义了一个全局数组
    public void Fill(ArrayList sdf)
    {
        ArrayList ar = sdf;
        Model.stock stockInfo = null;
        for (int i = 0; i < ar.Count; i++)
        {
            stockInfo = Bll.Stock.GetStockByUUID(ar[i].ToString());
            HtmlTextArea ht = new HtmlTextArea();
            ht.ID =stockInfo.uuid;
            arl.Add(ht.ID); //把我需要的内容添加进去
            ht.InnerText = stockInfo.re;
            Panel1.Controls.Add(ht);
        }
    }
    public void Button()
    {
        Model.stock stockInfo = null;
        for (int i = 0; i < arl.Count; i++) //在这里我去得不到他的值?显示的是为空
        {
            stockInfo = Bll.Stock.GetStockByUUID(arl[i].ToString());
            string uuuid = stockInfo.uuid;
            string vre = stockInfo.re;
           this.Page.GetType().InvokeMember("ReadUCMessage", BindingFlags.InvokeMethod, null, this.Page, new object[] { uuuid, vre});
        }
    }[/align]这是怎么回事?把上面的数组带到下面来确是为空的 没有数据 
说明:这是ascx页面的代码?我要在aspx中得到遍历出来的内容
或者可以把这个数组带到aspx中进行判断赋值?
这要怎么做?全局变量

解决方案 »

  1.   

    你赋值是在fill方法里赋的、在Button执行之前如果没有调用fill肯定是null啊
      

  2.   

    [align=left] public void Button()
        {
            this.Fill(sdf); //这个sdf报错  这个sdf哪里来?
            Model.stock stockInfo = null;
            for (int i = 0; i < arl.Count; i++)
            {
                stockInfo = Bll.Stock.GetStockByUUID(arl[i].ToString());
                string uuuid = stockInfo.uuid;
                string vre = stockInfo.re;
                Response.Write("<script>alert('编号为" + uuuid + "内容为" + vre + "')</script>");
                this.Page.GetType().InvokeMember("ReadUCMessage", BindingFlags.InvokeMethod, null, this.Page, new object[] { uuuid, vre});
            }
        }[/align]
      

  3.   

    debug一下啦,这句可能没执行arl.Add(ht.ID); //把我需要的内容添加进去
      

  4.   

    public static ArrayList arl = new ArrayList(); 或者放在session里面
      

  5.   

    把它放Session怎么做?没有一点思路了!!
      

  6.   

        public static ArrayList arl = new ArrayList();加一个static就可以咯!!