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;
}
else
{
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();
sqlAdpt.Fill(ds);
DataGrid1.DataSource=ds;
DataGrid1.DataBind();
}
\Here is the way to compare
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
float qc1Target=
float.Parse(System.Configuration.ConfigurationSettings.AppSettings["QC1Target"]);
float qc2Target=
float.Parse(System.Configuration.ConfigurationSettings.AppSettings["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)
{
e.Item.Cells[1].Text=e.Item.Cells[1].Text.Substring(5,2)+e.Item.Cells[1].Text.Substring(8,2);
e.Item.Cells[2].Text=e.Item.Cells[2].Text.Substring(e.Item.Cells[2].Text.Length-4,4);
if (float.Parse(e.Item.Cells[4].Text)<qc1Target)
{
e.Item.Cells[4].ForeColor=Color.Red;
}
e.Item.Attributes.Add("onmouseover","javascript:this.style.cursor='hand';oldColor=this.style.backgroundColor;this.style.backgroundColor=newColor;");
e.Item.Attributes.Add("onmouseout","javascript:this.style.cursor='hand';this.style.backgroundColor=oldColor;");
}