Question

I have a HyperLink along with other controls such as Label etc in a GridView. The Label's in the GridView are dynamically populated like this:

<asp:Label ID="Label1" runat="server" Text='<%# Bind("ClientName") %>'></asp:Label>

I am now trying to do something similar with HyperLink, as in:

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='http://www.company.com?clientname=<%# Bind("ClientName") %>'>Client Name</asp:HyperLink>

This doesn't give me any errors, but the link becomes this:

http://www.company.com/?clientname=<%# Bind("ClientName") %>

instead of something like this:

http://www.company.com/?clientname=oshiro

Anyone know how to get the link to work properly instead of just outputing the asp.net code?

Was it helpful?

Solution

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("ClientName", "http://www.company.com/?id={0}") %>'>Client Name</asp:HyperLink>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top