Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to pass an array from one Web form to another in ASP.net with c#

Posted on 2009-05-06
13
Medium Priority
?
700 Views
Last Modified: 2012-05-06
how to pass an array from one Web form to another in ASP.net with c#
0
Comment
Question by:tatchis1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +2
13 Comments
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 24320721
I would use Session variables...
0
 
LVL 10

Expert Comment

by:ALaRiva
ID: 24320732
If you are using Server.Transfer to go to the other page, then store it in the ViewState.

If you are not using Server.Transfer, then store it in the SessionState.

Make sure and remove it from the SessionState once you are done with it.

HTH
- Anthony
0
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 24320763
Here's how i would do it in VB.NET... i'm sure you can translate this quite easily:

        Dim arr(50) As String
        arr(1) = "Hello"
        arr(2) = "World"
        Session("MYARRAY") = arr
        Page.Response.Redirect("http://somewhere.com/myotherpage.aspx")

Then in your other page...
        ArrayFromOtherSite = Session("MYARRAY")

There's of course other methods like passing parameters after the URL like this:
http://somewhere.com/myotherpage.aspx?param1=Hello¶m2=World

but it's up to you...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:CJMilner
ID: 24321024
Serialize the array and then either:
- put it in the viewstate
- post it
- alter the postback url on a button click
- session vars
or querystring (if it's not too long)

Hope this helps

0
 
LVL 9

Accepted Solution

by:
AsishRaj earned 1500 total points
ID: 24322267
Well it simple - cdebel has given you the easiest way out
Populate your array
then save your array into the session
    Session("sessionArrayName") = yourArray;

go to which ever page you want

Declare a new array

string[] newarray = new string[arraysize];

newarray = Session("sessionArrayName") ;
0
 

Author Comment

by:tatchis1
ID: 24325184
I want to pass my parmeter using this method but I'm receiving an error.

Response.Redirect("CondemnedStockSummary.aspx?Value1" = txtStart.Text);
0
 
LVL 1

Expert Comment

by:CJMilner
ID: 24325201
Move the equals inside the string and add a + to the end of the string to concatenate the variable with the string. Like this

Response.Redirect("CondemnedStockSummary.aspx?Value1=" + txtStart.Text);
0
 

Author Comment

by:tatchis1
ID: 24325706
Can I do more than one parameters with this method?
Response.Redirect("CondemnedStockSummary.aspx?Value1=" + txtStart.Text);
0
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 24330932
tatchis1: please, next time that you ask a question and get correct answers from people, don't accept a single answer as you did.  

And about your last comment, check my comment #24320763 ... the answer is already there!
0
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 24330951
its especially frustrating when the person who is marked as having the good answer says:
"Well it simple - cdebel has given you the easiest way out is to..."
0
 
LVL 9

Expert Comment

by:AsishRaj
ID: 24349739
I agree, i will post Free Points For You Shortly
0
 
LVL 9

Expert Comment

by:AsishRaj
ID: 24349756
0
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 24351193
All what the askers have to do is to press the "REQUEST ATTENTION" button if my memory is good, then ask to split the points and the manager of this zone will help.

The important thing is that the asker understand how to do splits points for next time because if he keep doing this, people might refuse to answer him.  (same if he give a grade E to someone who gave a good answer too).
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question