Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server.Transfer problem

Status
Not open for further replies.

LauraCairns

Programmer
Jul 26, 2004
173
0
0
GB
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());
}
}
}
 
Can't you use Session instead of viewstate? The arraylist will then automatically be accessible on the page you redirect to?

Code:
Session("sessionVariableName") = arrayListName
 
Can't use session incase the users don't have cookies enabled. I think thats the reason anyway. Cheers for the suggestion
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top