title: How to use Eval statement to check a column value
body: <pre><code>&lt;asp:GridView ShowHeaderWhenEmpty="false" AlternatingRowStyle-BackColor="#EBE9E9" AutoGenerateColumns="false" OnSorting="yourTasksGV_Sorting" AllowSorting="true" ID="yourTasksGV" runat="server" ClientIDMode="Static" EmptyDataText="You currently have no tasks assigned to you" OnRowDataBound="yourTasksGV_RowDataBound" OnRowCreated="yourTasksGV_RowCreated"&gt;
      &lt;Columns&gt;
  &lt;asp:TemplateField HeaderStyle-Width="2%"&gt;
      &lt;ItemTemplate&gt;
          &lt;asp:ImageButton ImageUrl="~/theImages/Dependencies.png" CssClass="gvTaskDep btnShowDepend" runat="server" ID="btnShowDepend" OnCommand="btnShowDepend_Command" CommandName="TaskDepend" AlternateText='&lt;%#Eval("Object") + "," + Eval("FK") %&gt;' CommandArgument='&lt;%#Eval("Object") + "," + Eval("FK") %&gt;' ToolTip="Click to view Dependencies" /&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
          &lt;asp:HyperLinkField HeaderStyle-Width="16%" Target="_self" DataNavigateUrlFields="Task Detail" DataTextField="Task Name" DataNavigateUrlFormatString="" HeaderText="Task Detail" SortExpression="Task Name" ItemStyle-CssClass="taskTableColumn" /&gt;
          &lt;!-- ADD ANOTHER COLUMN HERE --&gt;
          &lt;asp:BoundField HeaderStyle-Width="10%" DataField="Workgroup" HeaderText="Workgroup" SortExpression="Workgroup" ItemStyle-CssClass="taskTableColumn" /&gt;
          &lt;asp:BoundField HeaderStyle-Width="7%" DataField="Status" HeaderText="Status" SortExpression="Status" ItemStyle-CssClass="taskTableColumn" /&gt;
          &lt;asp:BoundField HeaderStyle-Width="7%" DataField="Due Date" HeaderText="Due" SortExpression="Due Date" ItemStyle-CssClass="taskTableColumn" /&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>I am populating my GridView like this:</p>
  
  <pre><code>using (SqlConnection conn = new SqlConnection(gs))
  {
      try
      {
          SqlCommand cmd = new SqlCommand(query, conn);
  
          SqlDataAdapter da = new SqlDataAdapter(query, conn);
  
          myDataSet = new DataSet();
          da.Fill(myDataSet);
  
          myDataView = new DataView();
          myDataView = myDataSet.Tables[0].DefaultView;
  
          yourTasksGV.DataSource = myDataView;
          yourTasksGV.DataBind();
  
      }
      catch (Exception ex)
      {
          string error = ex.Message;
      }
  }
  </code></pre>
  
  <p>How can I modify my ASP.net GridView on this line: <code>&lt;!-- ADD ANOTHER COLUMN HERE --&gt;</code>, where the column will check the value in column <code>Due Date</code> in each row and make the background color red, if the <code>Due Date</code> column value is before today's date.</p>
  
  <p>I would like to use an <code>Eval</code> statement.</p>
  
  <p>This is what I have:</p>
  
  <pre><code>public string GetTodayDate()
  {
      return DateTime.Now.ToString("mm-dd-yyyy");
  }
  
  &lt;asp:TemplateField HeaderText="V%"&gt;
      &lt;ItemTemplate&gt;
          &lt;!-- FILL ENTIRE CELL? --&gt;
          &lt;asp:Panel ID="pnlTaskStats" Width="100%" Height="100%" runat="server" BackColor="&lt;%# (Eval("Due Date").ToString() &lt; GetTodayDate()) ? "#C00000" : "" %&gt;"&gt;&lt;/asp:Panel&gt;
      &lt;/ItemTemplate&gt;                   
  &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>`Operator '&lt;' cannot be applied to operands of type 'string' and 'string'`
  </code></pre>