title: How do I change the background color of a row in a GridView if a checkbox in the row is enabled?
body: <p>I would like to change the background color of all the rows with value for "active" column unchecked in a GridView. I tried the following way but it doesn't work:</p>
  
  <pre><code> protected void GdvDetails_RowDataBound(object sender, GridViewRowEventArgs e)
  {
      CheckBox chkItem = null;
      foreach (GridViewRow grRow in GdvDetails.Rows)
      {
          if (grRow.RowType == DataControlRowType.DataRow)
          {
              chkItem = (CheckBox)grRow.Cells[6].FindControl("active");
  
              if (chkItem.Checked )
              {
                  grRow.BackColor = Color.Red;
              }
  
          }
      }
  }
  </code></pre>
  
  <p>The error message is "Object reference not set to an instance of an object."</p>