Click here to Skip to main content
15,900,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have two webpages, one is a.aspx and second is b.aspx.
in a.aspx i have gridview with 10 records with 4 columns, and in b.aspx i have 4 textboxes.
and my query is

Now, i want to pass data from gridview in a.aspx to the textboxes b.aspx

can u please suggest me how to pass parameters.

N.Nagaraju
Posted

Hi,

please come to the point

Page 1

//Create & Build a String Array from the grid column values
string[] arrEmp = { "Emp101", "Abraham Lincoln", "Male", "50" };
//Add the array to Session
Session.Add("arrEmp", arrEmp);

Page 2

//Create & Build a String Array from Session
string[] arrEmpDetails = (string[])Session.Item("arrEmp");

//Assign the values to controls from Array
txtEmployeeID.Text = arrEmpDetails(0);
txtEmployeeName.Text = arrEmpDetails(1);
txtEmployeeGender.Text = arrEmpDetails(2);
txtEmployeeAge.Text = arrEmpDetails(3);

please let me know if you have any doubt

Regards,
thatraja
 
Share this answer
 
Depending on the requirement/security/performance/UI implementation, there can be various ways to pass on data from one page to other.

Session being one of them already explained in one of the answers. You can also pass on the values using querystring, cookies, etc (various other state management techiniques that are applicable across the pages)

Adding to all that, In ASP.NET2.0 a new feature called 'PreviousPage' was added. This is something UI implementation based. Posting one page to another after a button click or so - in this scenario you can access the previous page controls and thus there values.
Refer:
Cross-Page posting for more details.[^]
 
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