In a GridView, I’m trying to show either one column or an other using a public Boolean property:
<Columns> ... <asp:BoundField Visible='<%= !ShowPurchaseDate %>' DataField='Published' HeaderText='Publicerad' SortExpression='PriceRange' DataFormatString='{0:yyyy.MM.dd}' HtmlEncode='false' /> <asp:BoundField Visible='<%= ShowPurchaseDate %>' DataField='OrderDate' HeaderText='Köpt' SortExpression='OrderDate' DataFormatString='{0:yyyy.MM.dd}' HtmlEncode='false' /> ... </Columns>
But I’m getting an error message saying that it’s not possible to create a System.Boolean from a string that contains <% !ShowPurchaseDate %> for property Visisble.
How can I achive this?
UPDATE:
<%# !ShowPurchaseDate %> doesn’t work either as there’s no databinding going on.
Using a protected funktion doesn’t work either (same error message as with property).
I solved it through:
Is this the best solution?