Reputation: 225
I'm trying to retrieve a URL parameter and pass it into a HyperLinkField inside my GridView.
The URL looks like http://application.com/dynamic.aspx?locale=us. I need to pull the value of the locale param and include it in the asp:HyperLinkField. I know that I can retrieve this param in the code behind like this:
Request.QueryString["locale"].ToString()
But is it possible to retrieve this value inside the .aspx?
<asp:HyperLinkField DataTextField="ref_id" DataNavigateUrlFields="???,ref_id" DataNavigateUrlFormatString="dynamic.aspx?locale={0}&id={1}" Text="ID" HeaderText="ID" SortExpression="ref_id" >
Upvotes: 0
Views: 253
Reputation: 35514
Better switch to a TemplateField. You have much more control that way.
<asp:TemplateField HeaderText="ID">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# string.Format("/dynamic.aspx?locale={0}&id={1}", Request.QueryString["locale"], Eval("ref_id")) %>'><%# Eval("ref_id") %></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
Upvotes: 1