title: Highlight GridView row when a condition is met
body: <p>I'm using <code>VS2005 C# Server-side</code> coding.</p>
  
  <p>I'm curious to know that in <code>VS2005 version</code>, is it possible to <code>highlight</code> a row in a GridView when a condition is met? E.g. If column <strong>Risk</strong> is stored as <strong>high</strong> in the database for that specific row, the row will be <code>highlighted in Red</code>.</p>
  
  <p>Is it possible?</p>
  
  <hr>
  
  <p><strong>Edit:</strong></p>
  
  <p>Current code:</p>
  
  <pre><code>protected void GridView1_OnRowDataBound(Object sender, GridViewRowEventArgs e)
  {
  
  if (e.Row.RowType == DataControlRowType.DataRow)
  {
      // do your stuffs here, for example if column risk is your third column:
      if (e.Row.Cells[3].Text == "H")
      {
          e.Row.BackColor = Color.Red;
      }
  }
  }
  </code></pre>
  
  <p>I assume column cell starts from 0, so mine is at cell 3. But the color still does not change. </p>
  
  <p>Anyone has any idea?</p>