Change Background color of last updated record in Gridview in Asp.net
Here in this post,i m gonna show how to change background color of last updated record in gridview.
Normally what happens after we have updated any record we redirect or bind grid again, so grid comes to first page and we dont know which record we updated if there are many records.
Lets say we have a gridview with 15 records and paging of 5.
If we go to page 2 and click on “edit” link of 8th record in gridview and update that record, now after that we have to change the background row color of 8th record in gridview on 2nd page. So for that we have to maintain the primary key of that record and page index in session whenever we call edit method.
Now on gridview row databound you have to do this code:
protected void Gv_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)
int id = Convert.ToInt32(Gv.DataKeys[e.Row.RowIndex].Value.ToString());
if (id == Convert.ToInt32(Session[“pkid”]))
e.Row.CssClass = “UpdateRecordCss”;
also after binding grid you have to maintain page index
GvMake.PageIndex = Convert.ToInt32(Session[“pgindex”]);
Css for that is as follows:
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=’#B09900′,EndColorStr=’#FFF192′); /*FILTER: progid:DXImageTransform.Microsoft.Alpha( style=1,opacity=25,finishOpacity=100,startX=0,finishX=100,startY=100,finishY=0);*/