Configuring a SQLDataSource - passing a parameter from a gridview to a DetailsView on a separate page


I have a gridview on one page which summarises information but would like to be able to select a line to open up a DetailsView. Now I know how to do this if your gridview and detailsview are on the same page as you can reference the parameters easily with the nominated datakeyname.

What I would like to do is open up a separate page to display the detailsview. My question is how do I link parameters from one page to another? I have tried configuring the SQLdatasource but there are obviously no references to a grid view on a different page.

Many thanks in advance

Who is Participating?
carlnorrbomConnect With a Mentor Commented:

Pass the parameter using a QueryString:

Dim strUrl As String = "~/DetailsPage.aspx?ID=" & GridView1.SelectedValue.ToString

Or using a Session parameter, i.e:

Session("ID") = GridView1.SelectedValue.ToString

And on the new page add a datasource and use either a QueryString parameter or a Session parameter.

crossraAuthor Commented:
That's brilliant. I used the Session parameter and it worked a treat.

Thanks Carl.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.