passing data from one page to another

B

Brian Smith

I have a .aspx page (we'll call it Form1) with a
datagrid on it. The datagrid is populated from a dataset
that I manually entered data into (the data isn't in a
database). The datagrid on Form1 also has a button column
on it.
I have another .aspx page (Form2) with an
unpopulated datagrid on it. I want to populate it with
all the columns from the row where the button was clicked
on Form1.
I know how to do what I want with the datagrid
formatting. I know how to open the second page with
javascript. I just don't know how to pass the row from
Form1 to Form2. It has been recommended to me to use a
Cache but I don't know where to begin. I know how to add
the data to a cache, but how do I access it from the
second page?

Any help is greatly appreciated.

Thank you,

Brian Smith
 
W

Wim Hollebrandse

It wouldn't make sense to add the items to the cache unless your data is the
same throughout your web app, ie. not user session specific.

You might want to use the Context object (which is a Page property) and add
your items to it using:

Context.Items.Add("dr1",drMyDataRow);

Follow this up with a Server.Transfer("page2.aspx"); and you will be able to
retrieve the Items from the Context object again.

This is a very effective way of passing data between ASP.NET pages.

Hope that helps.

Cheers,
Wim Hollebrandse
http://www.wimdows.com
http://www.wimdows.net
 
W

Wim Hollebrandse

I forgot to add...

....that is to say if you don't want to use the Session object...
 
T

Todd Thompson

I think the problem your recommended solution may be that he isn't using
Server.Transfer or even Response.Redirect. If I'm understanding his
approach correctly, he is having the client page Form1 open the second page
without going back to the server first.

If this data is fairly static (seems to be implied since it isn't a
database), then I would suggest in opening the second page you simply pass
back, in the query string, some value from a hidden field that identifies
that selected row and its corresponding data.

Todd Thompson
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top