Dear all, let me explain how my datagrid work. The datagrid have 10 columns and 21 rows. The datagrid value will be updated every 5 minutes. Actually what I want is to compare the value before 10minutes with the current value which show in the datagrid. The value that I would like to compare is "e.Item.Cells[6]" which name Final_qty. Because of the datagrid is updated every 5 minutes. It is difficult to me to store the value before 10 minutes. So I try the way to only compare the Final_Qty value 5 minutes before and current value. If the value that I compare is the equal. Then {e.Item.Cells[6].BackColor=Color.Blue;}. The problem is, what is the (if statement) should I write? I do not know how to write the comparison between previous value and current value. Please give me a hand if u know. Thanks.

\This is the coding that insert into the datagrid.

private void dGridBind()
    string lines= System.Configuration.ConfigurationSettings.AppSettings["Lines"];

        if (lines!=null)
        lines="top " +lines;
            lines="top 100";

        string strSQL="SELECT "+lines+ " * From PICS_R where 1=1";
        strSQL+=" and Line_ID like 'V%'"; 
        strSQL+="order by Date_Time desc, Line_ID";

        SqlDataAdapter sqlAdpt=new SqlDataAdapter(strSQL,sqlConn);
        DataSet ds=new DataSet();

\Here is the way to compare

private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
        float qc1Target=
        float qc2Target=

        lblTarget.Text="QC1 Target: "+qc1Target.ToString("0.00%");
        lblTarget.Text+=", QC2 Target: "+qc2Target.ToString("0.00%");

        if (e.Item.ItemType==ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem) 

            if (float.Parse(e.Item.Cells[4].Text)<qc1Target)


Unless you are storing the previous value anywhere it is only accessible during the CellValidating event which only fires when a cell loses focus.

You said you want to compare the current value to the value 10 minutes ago; If you are updating the value every 5 minutes then you need the value before last. The only way to have access to those variables is to store them in a collection seperate from the datagridview.