Search code examples
c#asp.net.netrepeaterfriendly-url

Databinding inside frendly url


This is inside a repeater.

Databinding does not work inside the friendlyurl but works fine outside. ProductName works but not ProductID. Friendly url works fine if i hardcode the ProductID

<li><a href="<%: FriendlyUrl.Href("~/Product", DataBinder.Eval(Container.DataItem, "ProductID")) %>"><%# DataBinder.Eval(Container.DataItem, "ProductName") %></a></li>

i get this error.

The name 'Container' does not exist in the current context

the Container word inside the friendlyurl is red underlined in visual studio


Solution

  • If you change to (note the #), this should work...

    <%# FriendlyUrl.Href("~/Product", DataBinder.Eval(Container.DataItem, "ProductID"))