Search code examples
c#asp.netparsinglabeleval

Can the text in label contain eval?


  <asp:Label ID="lblprodId" runat="server" Text="<%# Eval("flavourID") %>"></asp:Label>

I got parser error when i run this page.When I change it.

<asp:Label ID="lblprodId" runat="server" Text=""><%# Eval("flavourID") %></asp:Label>

When i run this page there is no error


Solution

  • I use to consider that a parser error. You can get this working doing this:

    <asp:Label ID="lblprodId" runat="server" Text='<%# Eval("flavourID") %>'></asp:Label>
    

    Note: I changed double quotes with single quotes.