Reputation: 685
I have an ASP.net Web Application containing 2 pages, viz; default.aspx (form to capture user data and insert into the database) and confirmation.aspx (To print the receipt for the data inserted). This is a Booking App. The User enters data in default.aspx and the data is stored in a database using the default.aspx. I have managed to capture the identity record id after inserting the record. I would like to:
a. Transfer this unique Identity ID (stored in a variable var id) to Confirmation.aspx only on a successful data insert b. Capture the ID in confirmation.aspx c. Execute a SQL Query to fetch the record and display it in a GRID View. This is basically a receipt that would be printed for the user
Could you please suggest on using: a. Use session state. b. Create public properties in the source page and access the property values in the target page.
I am a beginner in ASP.net.... Thanks in advance
Upvotes: 0
Views: 739
Reputation: 685
I did something like this:
Default.aspx: Response.Redirect("confirmation.aspx?ID=" + id);
Confirmation.aspx:
string id = null;
id = Request["ID"].ToString();
Response.Write("This is the Confirmation Page" + id);
Upvotes: 2
Reputation: 4100
Here are some links that show you all the methods(with examples) you can use to pass data between pages:
http://msdn.microsoft.com/en-us/library/6c3yckfw(v=vs.100).aspx http://www.codeproject.com/Tips/589911/Passing-Value-Between-Pages-in-ASP-NET http://www.mikesdotnetting.com/Article/192/Transferring-Data-Between-ASP.NET-Web-Pages
Hope it helps!
Upvotes: 1