Reputation: 14836
ASP.NET 2.0
As much as I try, I can't seem to bind the Visible property to data item property:
<asp:Panel runat="server" Visible="<%#(bool)Eval("IsBoolean")%>">X</asp:Panel>
I always get this error:
Cannot create an object of type 'System.Boolean' from its string representation '"<%#(bool)Eval("IsBoolean")%' for the 'Visible' property.
But this works:
<asp:Panel runat="server" Visible="<% true %>">X</asp:Panel>
What am I doing wrong? I mean, besides using ASP.NET 2.0?
Upvotes: 0
Views: 1024
Reputation: 14836
The problem is that the parser is unable to keep track of the quotations.
The solution is to use single quotes in the markup and keep double quotes in the C#/VB:
<asp:Panel runat="server" Visible='<%#(bool)Eval("IsBoolean")%>'>X</asp:Panel>
Upvotes: 0