Click to See Complete Forum and Search --> : Asp.net Ajax, Update Panel


Seboko
06-16-2009, 01:23 PM
Hi,
I am using a datagrid to diplay a number of items and their prices. I am using an asp:UpdatePanel and an asp:Timer that refreshes the page every 30 seconds (to fetch new prices). I would like to change the background color of ONLY the cells containing prices that have changed after the refresh.

Does anybody know how I can achieve this?

Thanking you in advance...

jenbuh
07-15-2009, 12:34 PM
I'm not sure if this will work for you but worth posting anyway.

I have a site that uses a gridview and I display link buttons based on certain criteria. I would assume it would be the same sort of process.

In the RowDataBound event handler you might be able to do something like this:

if (e.Row.RowState == DataControlRowState.Edit)
{
}
else
{
//Here you could find the label that displays the price
LinkButton lnk = (LinkButton)e.Row.FindControl("lnkUpdateStatus");
if (e.Row.RowType == DataControlRowType.DataRow)
{
//Here you would somehow compare the old value to the new value (Maybe you have to save the old value also until the next update?)
if (DataBinder.Eval(e.Row.DataItem, "Status").ToString() == "New" & DataBinder.Eval(e.Row.DataItem, "ApproverID").ToString() == Server.HtmlEncode(emp))
{
//Here you would set the back color of the label
lnk.Visible = true;
}
else
{
lnk.Visible = false;
}
}
}

Hope that helps.

}