title: How to set the RowStyle of a GridView row depending on a property of the Object that the row is being bound to
body: <p>I'm currently using a GridView and I want to set the CssClass for the Row depending on a property of the object that the row is being bound to.</p>
  
  <p>I tried the following but it does not work (see comments):</p>
  
  <pre><code>&lt;asp:GridView id="searchResultsGrid" runat="server" AllowPaging="true" PageSize="20" AutoGenerateColumns="false"&gt;
  
  &lt;!-- The following line doesn't work because apparently "Code blocks 
  aren't allowed in this context: --&gt;
    &lt;RowStyle CssClass="&lt;%#IIF(DataBinder.Eval(Container.DataItem,"NeedsAttention","red","") %&gt;
  
    &lt;Columns&gt;
  &lt;!--............--&gt;
    &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Now I could simply handle the GridView's RowDataBound event and change the css class of the row there...but I'm trying to keep a clear separation between the UI and the page/business logic layers.</p>
  
  <p>I have no idea how to accomplish this and I'm looking forward to hearing any suggestions.</p>
  
  <p>Thanks,</p>
  
  <p>-Frinny </p>