Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can I pass more than one values to another page when click the button.
I read very article but all of them say how pass one item two another page
please help me.
Posted

You might try below,

1) Construct a Class for example, SessionObject with Properties. The no of Properties depends on how many different values your would like to pass around the pages.
2) Store a object of SessionObject into the Session, upload related value from the SessionObject when click on the Button and from the other page just access the SessionObject from the Session.

There would be other solutions as well.

More detail about Session[^].

:)
 
Share this answer
 
Comments
raj ch 10-Oct-11 2:08am    
my vote 5
Mohammad A Rahman 10-Oct-11 3:20am    
Thanks Supriya :)
How to: Pass Values Between ASP.NET Web Pages[^] is an excellent startup tutorial with respect to this question.
 
Share this answer
 
Read up on QueryString, but you can so long try this:
C#
Response.Redirect( "NextPageName.aspx?query1=" + txtBox1.Text + "&query2=" + txtBox2.Text + "&query3=" + txtBox3.Text + " );
//you can attach as many queries in the query string


To retrieve the values from the query string:
C#
String query1 = ( Request.QueryString[ "query1" ] != null ) ? Request.QueryString[ "query1" ] : String.Empty;

String query2 = ( Request.QueryString[ "query2" ] != null ) ? Request.QueryString[ "query2" ] : String.Empty;

String query3 = ( Request.QueryString[ "query3" ] != null ) ? Request.QueryString[ "query3" ] : String.Empty;


Happy Coding,
Morgs
 
Share this answer
 
you can create one class that contains properties
in button click assign all the values to that properties and in another page access those properties by creating object for that class..if you want more i will give you code
 
Share this answer
 
U can use Querystring in the following way:

protected void Button1_Click(object sender, EventArgs e)
{
        string strName = "VINZ";
        string strAddress = "CEBU";
        string strDate = DateTime.Now.ToShortDateString();
        Response.Redirect(string.Format("TestNasad2.aspx?param1={0}&param2={1}&param3={2}",strName,strAddress,strDate));

}

The on Page2 you can get each values this way below

protected void Page_Load(object sender, EventArgs e)
{
        if ((Request.QueryString["param1"] != null && Request.QueryString["param2"] != null) && Request.QueryString["param3"] != null)
        {
            string name = Request.QueryString["param1"];
            string address = Request.QueryString["param2"];
            string date = Request.QueryString["param3"];

        }
}
 
Share this answer
 
Use session to pass the values between pages.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900