repeater ASP .NET databind to navigationURL

687 views Asked by At

I'm trying to bind an ID to an already defined navigation url from a hyperlink.

<asp:HyperLink ID="HyperLink4" runat="server" 
    NavigateUrl='accounts_history.aspx?accountId=<%# DataBinder.Eval(Container.DataItem, "Id") %>'>Historiek</asp:HyperLink>

This is my hyperlink. The <%# DataBinder.Eval(Container.DataItem, "Id") %> part works but using this method the hyperlink just sees it as clear text, resulting in the following link:

accounts_history.aspx?accountId=<%# DataBinder.Eval(Container.DataItem, "Id") %>

What is causing this?

1

There are 1 answers

0
Jack Spektor On

Try this

NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "Id", "accounts_history.aspx?accountId={0}") %>'

http://msdn.microsoft.com/en-us/library/2d76z3ck.aspx

You should place only databinding expression in property.