I have a page to search for products by their name. On many pages I work with product codes. If the user does not know the product code, I allow him to go to this page, search by name, and then select one of the results and return to the page from which he came.
In the search results by name, I install HyperLinkField, which redirects to a specific page with the product code parameter.
My code looks like this:
<asp:GridView ID="GridView1" Runat="server" DataSource='<%# GetData(pName.Text) %>' AutoGenerateColumns="False"> <Columns> <asp:BoundField DataField="Name"> <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle> </asp:BoundField> <asp:BoundField DataField="Code"></asp:BoundField> <asp:ImageField ControlStyle-Width="150px" ControlStyle-Height="150px" DataImageUrlField="PictureURL" ></asp:ImageField> <ASP:HYPERLINKFIELD text=">>" datanavigateurlfields="Code" datanavigateurlformatstring="priceUpdater.aspx?ProductCode={0}"></ASP:HYPERLINKFIELD> </Columns> </asp:GridView>
Where GetData is a function that returns an object of type Product with fields, name, code, image, etc.
As you can see, this link in HYPERLINKFIELD will be redirected to a page called priceUpdater with the product code parameter.
I want this page to be dynamic. I tried adding a parameter to the search page, for example,
<%string pageRequested = Page.Request.QueryString["SearchScreen"];%>
and now I'm trying to use HYPERLINK as follows:
<ASP:HYPERLINKFIELD text=">>" datanavigateurlfields="Code" datanavigateurlformatstring="<%=pageRequested%>.aspx?ProductCode={0}"></ASP:HYPERLINKFIELD>
But the page the link is linking is as plain text as wrriten ( http://mysite.com/%3C%=pageRequested% > .aspx? ProductCode = 2450)
How can I do this job?
Thanks!
source share