title: Looping through gridview and change certain column font colour
body: <p>So I have a gridview and I wanted to make certain columns text a different colour... i.e every column that says actual I want this text to be green... can anybody help? My gridlooks similar to this.</p>
  
  <pre><code>Hour - actual A - target A - actual aa - target aa - actual b - target b.
  </code></pre>
  
  <p>And finally is there a way to reset the data in my gridview after a certain amount of time... i.e <code>shiftstart 6am-2pm 2pm-10pm 10pm-6am</code>... So the data refreshes after 8 hours back to zero.</p>
  
  <pre><code>   public void Refreshdata(int selectedProduct, DateTime shiftStart, DateTime shiftEnd)
          {
              BizManager biz = new BizManager();
  
              GridView1.DataSource = biz.GetPacktstatisticsForShift(
                  shiftStart
                  , shiftEnd
                  , selectedProduct).DefaultView;
              GridView1.DataBind();
  
   public DataTable CreatePackingStats(DataSet dset)
          {
              using (DataManager dmgr = new DataManager())
              {
                  DataTable target = dset.Tables[0];
  
                  DataTable actual = dset.Tables[1];
  
                  DataColumn[] cols = new DataColumn[1];
                  cols[0] = actual.Columns["Hour"];
                  actual.PrimaryKey = cols;
  
                  DataTable final = new DataTable();
  
  
  
                  // Create table columns
                  foreach (DataColumn col in target.Columns)
                  {
                      final.Columns.Add(new DataColumn(col.ColumnName, col.DataType));
                      if (col.ColumnName.Contains("Target"))
                      {
                          // Add an equivilant actual column
                          string newColumnName = col.ColumnName.Replace("Target", "Actual");
                          final.Columns.Add(newColumnName, col.DataType);
                      }
                  }
                  //// Add rows to new table
                  foreach (DataRow row in target.Rows)
                  {
                      string key = row["Hour"].ToString();
  
                      DataRow newRow = final.Rows.Add();
                      // Store column value
                      foreach (DataColumn col in final.Columns)
                      {
  
  
                          if (col.ColumnName.Contains("HOUR") || col.ColumnName.Contains("Target"))
                          {
                              newRow[col.ColumnName] = row[col.ColumnName];
                          }
                          else
                          {
                              // Find actual data
                              DataColumn actColumn = actual.Columns[col.ColumnName] as DataColumn;
                              if (actColumn == null)
                              {
                                  newRow[col.ColumnName] = 0;
                              }
                              else
                              {
                                  if (string.IsNullOrEmpty(actual.Rows.Find(key)[col.ColumnName].ToString()))
                                  {
                                      newRow[col.ColumnName] = 0;
                                  }
                                  else
                                  {
                                      newRow[col.ColumnName] = actual.Rows.Find(key)[col.ColumnName].ToString();
                                  }
  
                              }
  
                          }
  
                      }
                  }
                  return final;
  </code></pre>
  
  <p>The <code>CreatePackingStats</code> is populating my grid with added columns FYI.</p>
  
  <p>I guess there is a way to add colour text whilst the code is looping through the data and creating extra columns, not sure how to do this tho.?</p>
  
  <p>And also the <code>CreatePackingStats</code> is located in a class and not in the page behind aspx.</p>
  
  <p>Sorry about all the questions I am new and learning, all your help will help to develop and I appreciate all the help I receive.</p>