Search code examples
asp.netrepeaterxmldatasource

asp:HyperLink build NavigateUrl within Repeater using XPATH data


I am using a repeater for some products I am listing.

I'm trying to build an asp:HyperLink NavigateUrl using both hardcoded text as well as XPATH data.

NavigateUrl='mypage.aspx?ID=<%#XPath("THEID")%>&name=<%#XPath("THENAME")%>'

Obviously this isn't working.

Does anyone know how to make this work?


Solution

  • This should work:

    <asp:HyperLink 
        runat="server" 
        NavigateUrl='<%# string.Format("mypage.aspx?ID={0}&name={1}", XPath("THEID"), XPath("THENAME")) %>' 
        Text="some link" 
    />