c# - asp:GridView HYPERLINKFIELD - asp code inside datanavigateurlformatstring -


i have page search products name. in many pages work product codes. if user not know product code, let him go page, search name, , select 1 of results , page came from.

in results of search name set hyperlinkfield redirect page , paramter of product code.

my code 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 function returns object of type product fields, name,code,image etc.

as can see, link in hyperlinkfield redirect page called priceupdater parameter of product code.

i want page dynamic. have tried add paramter search page this

 <%string pagerequested = page.request.querystring["searchscreen"];%> 

and im trying use hyperlink this:

<asp:hyperlinkfield text=">>" datanavigateurlfields="code"  datanavigateurlformatstring="<%=pagerequested%>.aspx?productcode={0}"></asp:hyperlinkfield>  

but page link reffers plain text wrriten (http://mysite.com/%3c%=pagerequested%>.aspx?productcode=2450)

how can make work?

thank you!

try that:

<asp:templatefield>                      <itemtemplate>     <asp:hyperlink text=">>" navigateurl='<%# string.format("~/{0}.aspx?productcode={1}",page.request.querystring["searchscreen"],eval("code")) %>'></asp:hyperlink>  </itemtemplate> </asp:templatefield> 

Comments