ASP.net: Dynamic BoundFields
<p>In a GridView, I'm trying to show either one column or an other using a public Boolean property:</p>

<pre><code>   &lt;Columns&gt;
   ...

    &lt;asp:BoundField Visible="&lt;%= !ShowPurchaseDate %&gt;" DataField="Published" HeaderText="Publicerad" SortExpression="PriceRange" DataFormatString="{0:yyyy.MM.dd}" HtmlEncode="false" /&gt;

    &lt;asp:BoundField Visible="&lt;%= ShowPurchaseDate %&gt;" DataField="OrderDate" HeaderText="Köpt" SortExpression="OrderDate" DataFormatString="{0:yyyy.MM.dd}" HtmlEncode="false" /&gt;

   ...
  &lt;/Columns&gt;
</code></pre>

<p>But I'm getting an error message saying that it's not possible to create a System.Boolean from a string that contains &lt;% !ShowPurchaseDate %> for property Visisble.</p>

<p>How can I achive this?</p>

<p>UPDATE:</p>

<p>&lt;%# !ShowPurchaseDate %> doesn't work either as there's no databinding going on.</p>

<p>Using a protected funktion doesn't work either (same error message as with property).</p>
