Click here to Skip to main content
15,908,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an initial page on an ASP.NET website that uses gridcontrol to list a set of records, each row has a link to another page, where a parameter is passed via a querystring, pretty standard stuff.
I update some other fields on this second details page using the id passed as the parameter.
The problem is that I want to embed a link into this second page (Detail01.aspx), that passes the same id to another page (Detail02.aspx), for further updates.
I'm using the following in the first starting page (MasterList.aspx):
<asp:HyperLinkField DataNavigateUrlFields="Episode_Key" DataNavigateUrlFormatString="Detail01.aspx?Episode_Key={0}" Text="Details" />
In the second page I have the following:
<selectparameters>
<asp:QueryStringParameter Name="Episode_Key" QueryStringField="Episode_Key" Type="String" DefaultValue="" />

Which is used for both another select and update.
I want to then pass on this id (Episode_Key) to another page (Detail02.aspx).
I have tried something like this inside the second page’s Formview:
<asp:HyperLink runat=server Text="Detail02" NavigateUrl='~/Detail02.aspx?Episode_Key=<%# Eval("Episode_Key") %>' />
where my code behind :
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Episode_Key.Value = Request.QueryString("Episode_Key").ToString()
End Sub
The main problem is that I haven't done this type of coding for years, and I'm very rusty, and frustrated, which is why I've posted this question, in the hope that some kind soul might provide an answer.
And yes, I have been looking at many various sites on the internet.

I’m happy to use hiddenfields, or session variables, or even just querystring parameter to pass on the id from one page to another.

What I have tried:

I have tried something like this inside the second page’s Formview:
<asp:HyperLink runat=server Text="Detail02" NavigateUrl='~/Detail02.aspx?Episode_Key=<%# Eval("Episode_Key") %>' />
where my code behind :
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Episode_Key.Value = Request.QueryString("Episode_Key").ToString()
End Sub<
Posted
Updated 26-Jun-18 5:20am
Comments
spirospap 25-Jun-18 23:15pm    
I have also tried this:

<asp:Label ID="Label1" runat="server" Text='<%# Bind("Episode_Key") %>' ReadOnly="true" />
<asp:HyperLink ID="Detail02" runat=server Text="Detail02" NavigateUrl='~/Detail02.aspx?Episode_Key=<%# Bind("Episode_Key") %>' />

the asp:Label will allow me to use the parameter, why won't the asp:hyperlink?

1 solution

If the Episode_Key is a column returned by your FormView's data source:
<asp:HyperLink runat=server Text="Detail02" 
    NavigateUrl='<%# Eval("Episode_Key", "~/Detail02.aspx?Episode_Key={0}") %>' 
/>

If it only exists in the query-string:
<asp:HyperLink runat=server Text="Detail02" 
    NavigateUrl='<%# String.Format("~/Detail02.aspx?Episode_Key={0}", Request.QueryString("Episode_Key")) %>' 
/>
 
Share this answer
 
Comments
spirospap 26-Jun-18 18:34pm    
Richard, if you were anywhere near Melbourne, Australia, I would gladly buy you a beer or three! Thank you so much!

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