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?
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.