HyperLink with NavigateUrl with Eval(). Where is the mistake?

abatishchev picture abatishchev · Nov 22, 2009 · Viewed 75.1k times · Source

First I was changing HyperLink.NavigateUrl in code-behind on Page_Load().

But after I decided to do it in design using Eval() method.

<asp:HyperLink runat="server"
     NavigateUrl='<%# String.Format("~/Refuse.aspx?type={0}&id={1}", Eval("type"), Eval("id")) %>' Text="Refuse" />

or

<asp:HyperLink ID="urlRefuse" runat="server"
     NavigateUrl='<%# String.Format("~/Refuse.aspx?type={0}&id={1}", Request["type"], Request["id"]) %>' Text="Refuse" />

where id and type - are variables from Request.

But it doesn't work. Only raw text 'Refuse' is shown. Where is my mistake? Thanks in advance.

Answer

Hamdy Mohamed picture Hamdy Mohamed · Feb 10, 2011

this is working great

NavigateUrl='<%# Eval("type","~/Refuse.aspx?type={0}") %>'