Short answer: NavigateUrl='<%# Eval("Key.Id", "ViewItem.aspx?id={0}") %>'
More detailed explanation:
The problem in your code is that you are using the data binding expression only for part of your web control attribute. You need to move everything inside the data binding expression.
First of all, this is a data binding expression:
<%# EXPRESSION %>
In principle, the rule of using a data binding expression for a web control attribute is that the expression should be the only one in the attribute:
<asp:HyperLink ID="lb" runat="server" Text='<%# EXPRESSION %>' NavigateUrl='<%# EXPRESSION %>' />
So your first Text attribute is correct. But your second NavigateUrl attribute is incorrect. Since you put ViewItem.aspx?id= as the value for the attribute, leaving + '<%# Eval("Key.Id") %>' outside any attribute, but inside the control tag.
Here is the correct syntax:
<asp:HyperLink ID="lb" runat="server" Text='<%# Eval("Key.Id") %>' NavigateUrl='<%# Eval("Key.Id", "ViewItem.aspx?id={0}") %>'/>
Note that we use the format string as the second parameter for Eval() . This is equivalent to the following, more explicit syntax:
<asp:HyperLink ID="lb" runat="server" Text='<%# Eval("Key.Id") %>' NavigateUrl='<%# String.Format("ViewItem.aspx?id={0}", Eval("Key.Id")) %>'/>
source share