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());
}
}
}
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());
}
}
}