Search code examples
c#asp.netlinkbutton

Compiler Error Message in row LinkButton declaration


I have the following ASP code:

<asp:LinkButton ID="LinkButton1" runat="server" Text="edit item" onclick='AddItem.aspx?catid=<%# Eval("CollectionID")%>' />

In this row i get Error compilation:

Compiler Error Message: CS1040: Preprocessor directives must appear as the first non-whitespace character on a line

Why do I get this error and how can i fix it? Thank you in advance!


Solution

  • You can do it in this way.

    <asp:LinkButton ID="LinkButton1" runat="server" Text="edit item" 
    PostBackUrl='AddItem.aspx?catid=<%# Eval("CollectionID")%>' />