Reprinted from: http://www.cnblogs.com/fly_dragon/archive/2010/09/03/1817252.html
1 protected voidGridView1_RowDataBound (Objectsender, GridViewRowEventArgs e)2 {3 //The mouse has been adapted color4 if(E.row.rowtype = = Datacontrolrowtype.datarow)//determines whether the current row belongs to a DataRow-type row5 {6 7 //Save the background color of the current row and give it a color when the mouse is on it.8 9E.row.attributes.add ("onmouseover","currentcolor=this.style.backgroundcolor;this.style.backgroundcolor= ' yellow ', this.style.fontweight= ';");Ten One //restores the background color to the previous color when the mouse is left A -E.row.attributes.add ("onmouseout","this.style.backgroundcolor=currentcolor,this.style.fontweight= ";"); - } the - - //Click Row to change row background color - if(E.row.rowtype = =Datacontrolrowtype.datarow) + { -E.row.attributes.add ("onclick","this.style.backgroundcolor= ' #99cc00 '; this.style.color= ' buttontext '; this.style.cursor= ' default ' ;"); + } A}
GridView add mouse-over highlight and click Row color change in ASP.