Contristo
Contristo

Reputation: 335

Passing Query String parameter to a DataNavigateUrl Format String

I am trying to alter an existing search page to also allow a user to find comparable records based on a query string. I fist have them select a parent and then reload the same existing search page with an added paramter to the URL "PID". Using this when I run the search again I want to be able to select a child record ID then go to a new page to compare. However I cannot get the oringal PID from the query string in the datanavigateUrlFormatString

<asp:HyperLinkField DataNavigateUrlFields="ID, " 
                DataNavigateUrlFormatString="~\Contributor\Search.aspx?LinkWizard=true&amp;CID={0}&amp;PID=" HeaderText="Select Child" 
                Text="Set Child" />

Essentially I need the PID to get pulled from the query string. How is this done, it seems it should have been simple but I can find nothing that works for me. Thanks.

Upvotes: 0

Views: 1316

Answers (1)

evothian
evothian

Reputation: 26

I'm not sure where you're using the HyperLinkField but can you change it to a TemplateField and use Eval? Something like this:

    <asp:TemplateField HeaderText="Select Child">
            <ItemTemplate>
                <asp:HyperLink runat="server" NavigateUrl='<%#Eval("ID",  "~/Contributor/Search.aspx?LinkWizard=true&CID={0}&PID=") + Request.QueryString["PID"]%>' Text="Set Child" />
            </ItemTemplate>
    </asp:TemplateField>

Upvotes: 1

Related Questions