Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to redirect a page ,from other page .I have written code to insert data into a table in a insert button.After this i want to redirect to one more page where i can display table data along with updated one also.I am new .net.Please give me simple step by step procudeure to do and please proide some sample code to do this
Posted

 
Share this answer
 
After inserting the data("This is the task which you are doing."), call the Redirect function of Response class. Try this:
C#
Response.Redirect("MyPage2.aspx");


--Amit
 
Share this answer
 
Comments
vinod.sambangi 20-Nov-12 5:16am    
SqlCommand cmd=new SqlCommand("Select * from EMPLOYEE_TABLE",con);
SqlDataReader dr=cmd.ExecuteReader();
while(dr.Read())
{
lblvalue1.Text=dr.GetValue(0).ToString();//first value of a employee table
lblvalue2.Text=dr.GetValue(1).ToString();//second value of a employee table
lblvalue3.Text=dr.GetValue(2).ToString();//third value of a employee table

}
vinod.sambangi 20-Nov-12 5:17am    
I have written this code.But It was printing only one row of the table but remaining rows are not printing .What should i do print each and every row of a table .I have written this code in page load.Please tell me
_Amy 20-Nov-12 5:28am    
Yes.. Because you are using sqldatareader. take a gridview and try this:
SqlCommand cmd=new SqlCommand("Select * from EMPLOYEE_TABLE",con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
Response.Redirect("MyPage2.aspx");


--Amit
Here two ways are available to transfer one page to other page.

Server.transfer("DestinationPage.aspx");
Response.Redirect("DestinationPage.aspx");
 
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