Writing arraylist items to the page

G

Guest

I've been working on some code which will hopefully allow me to transfer the
contents of an arraylist on one page over to another page. The Arraylist is
held in the viewstate object as it is populated on the on-click event of a
button. Im trying to move to another page and carry over the items in my
arraylist and write them to the page. The code ive been trying to work with
to achieve is detailed below. I am getting an error and im not sure exactly
why or what im doing wrong and was wondering if someone could have a look and
help me with this. To see exactly how my Arraylist is populated please see
my recent post. I've been advised to use the Server.Transfer to access the
arraylist on a seperate page, however as outlined below i've having some
difficulty achieveing this. Could someone please help me. Thanks

Im getting an error: -
Object reference not set to an instance of an object.
For the line
foreach (object o in debtor_enquiry.addresses)
in the page load event below.

Contained within the page where the ArrayList has been created. addresses is
the name of my arraylist.
private ArrayList Addresses1;
public ArrayList addresses
{
get
{
return Addresses1;
}
}

private void ArrayList_Click(object sender, System.EventArgs e)
{
Server.Transfer("ArrayListItemsDisplayed.aspx");
}

private void Page_Load(object sender, System.EventArgs e)
{
WebForm1 debtor_enquiry = base.Context.Handler as WebForm1;
if (null != debtor_enquiry)
{
// Add the logic here
foreach (object o in debtor_enquiry.addresses)
{
Response.Write(o.ToString());
}
}
}
 
G

Guest

Yeah sorry, was at lunch and just received it there now. got it to working in
a test app but can't get it to work for the way I have things set up. I
emailed you my code behind pages and would really appreciate it if you could
have a quick look. Sorry for bugging you I'm relatively new to programming
and have been thrown in at the deep end, but I really enjoy it and I'm
learning new stuff every day. Thanks for your help again. If your ever over
in Belfast I'll but you a beer!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top