Background
While trying out different code snippets as I worked on tweaking an ASPX app, I ran into a parser error.
BTW, the enhancement is detailed here.
Let us quickly go over the parser error.
Parser Error
Code
<asp:TemplateColumn HeaderText="Link" > <ItemTemplate> <!-- <asp:HyperLinkColumn HeaderText="Link" Text="Link" NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "eventLink") %>' Visible="True" Target="_blank" runat="server" > </asp:HyperLinkColumn> --> <asp:HyperLink HeaderText="Link" Text="Link" NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "eventLink") %>' Visible="True" Target="_blank" runat="server" > </asp:HyperLink> </ItemTemplate> </asp:TemplateColumn>
Parser Error
Image
Textual
Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.HyperLinkColumn does not have a DataBinding event. Source Error:
Correct
Here is the change.
Basically, it is to replace “<!–” and “–>” with “<%–” and “–%>“.
<asp:TemplateColumn HeaderText="Link" > <ItemTemplate> <%-- <asp:HyperLinkColumn HeaderText="Link" Text="Link" NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "eventLink") %>' Visible="True" Target="_blank" runat="server" > </asp:HyperLinkColumn> --%> <asp:HyperLink HeaderText="Link" Text="Link" NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "eventLink") %>' Visible="True" Target="_blank" runat="server" > </asp:HyperLink> </ItemTemplate> </asp:TemplateColumn>
Acknowledge
Crediting Scott Guthrie
Tip/Trick: Using Server Side Comments with ASP.NET 2.0
Link