Search code examples
c#asp.netdata-bindingweb-controls

How to apply a DataBinder.Eval to a Text property of a HyperLink


I use .NET and C#.

I use a Repeater control, inside I have this code.

<asp:HyperLink ID="HyperLink1" runat="server" Text="<%# DataBinder.Eval(Container.DataItem,"Title") %>"></asp:HyperLink>

ERROR:

Parser Error Message: The server tag is not well formed.

I'm not able to DataBind the Text property for the HyperLink control.

What I'm doing wrong here?


Solution

  • Replace double quote with a single quote

    <asp:HyperLink ID="HyperLink1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Title") %>'></asp:HyperLink>