I need to get data from gridview on one page to detailview on other page when I use select statement.I am able to do this on same page by using following code but not able to do this on different page
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
DetailsView1.PageIndex = GridView1.SelectedIndex;
}
Is it possible that when I use select in gridview on a particular page then only that row data appear on detail view of another page. please let me know asap.
Find the Best Webhosts on Internet on http://www.besthostonline.com
![]() |
0 |
![]() |
You could pass the ID of the record as a querystring to the other page e.g.
Then, you can read the id in your other page by using:Response.Redirect("otherpage.aspx?id=" & GridView1.SelectedIndex)
Request.Querystring("id")
Website Design Darlington - http://mdssolutions.co.uk
http://lessthandot.com - Experts, Information, Ideas & Knowledge
http://aspnetlibrary.com - An online resource for professional ASP.NET developersPlease remember to click "Mark as Answer" on this post if it helped you
![]() |
0 |
![]() |
You can also use Session Variable like below
I assumed that you have used the SELECT commandField in your GridView.
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < GrdiView1.Rows.Count; i++)
{
if (GrdiView1.SelectedIndex == i)
{
String id =GrdiView1.Rows[i].Cells[1].Text; //Gets the id value in the grid based on the selected index;
Session["Value"] = id;
Response.Redirect("SecondPage.aspx");
}
}
}
SecondPage.aspx
On page load you can get the value of your stored in the session variableprotected void Page_Load(object sender, EventArgs e)
{
string getid = Session["Value"].ToString();//Now you can bind your DetailsView based on that id
}
Regards,Vinz
"Code, Beer and Music" that's my way of being a programmer!
How to get your Forum Question Answered | Blog | CodeASP.NET
![]() |
0 |
![]() |
Thanks for replying.
How can I add a new row in my gridview I want automatically
a detailview of that row in a new page is created.
Find the Best Webhosts on Internet on http://www.besthostonline.com
![]() |
0 |
![]() |
You're Welcome! Anyways....you can refer to this article regarding that matter
http://www.koffeekoder.com/ArticleDetails.aspx?id=98
Regards,Vinz
"Code, Beer and Music" that's my way of being a programmer!
How to get your Forum Question Answered | Blog | CodeASP.NET
![]() |
0 |
![]() |