Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one gridview in default.aspx page as follows


ID Name Course Marks Result

1 A Eng 60 Pass
2 B Tam 70 Pass
3 C Mat 80 Pass
4 D Soc 90 Pass
5 E Sci 75 Pass


i want to display this gridview to another page default2.aspx in page load.

for that how to do in asp.net using c#

What I have tried:

.
Posted
Updated 24-Jan-18 0:13am
v2
Comments
Karthik_Mahalingam 24-Jan-18 0:42am    
call the same data-source in default2.aspx page load.
[no name] 24-Jan-18 0:43am    
Please user a user control and add the gridview to that user control and reference that in both the aspx page.
[no name] 24-Jan-18 1:25am    
ok . i tried this one in default1.aspx page in button click

DataTable Getdata = new DataTable();
dt = (DataTable)GridView1.DataSource;
Session.Add("Data", dt);
Response.Redirect("Default2.aspx");

And in the second page, page load i writeen the below code as follows

DataTable dt = new DataTable();
dt = (DataTable)Session["Data"];
Gridview1.DataSource = dt;
Gridview1.DataBind();
Gridview1.Visible = true;

it is working. The above code is working.
Sinisa Hajnal 24-Jan-18 6:15am    
You don't need new DataTable if you're assigning the value in the following line. Just call DataTable dt = (DataTable)Session["Data"]

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