HTML:
<Script type = "text/javascript">
Var oldrow = null;
Var currentcolor = null;
Var oldcolor = null;
Function selectx (row)
{
If (oldrow! = Null)
{
Oldrow. style. backgroundColor = oldcolor;
}
Row. style. backgroundColor = '# 99ccff ';
Oldrow = row;
Oldcolor = currentcolor;
}
</Script>
. Cs:
Protected void GridView1_RowDataBound (object sender, GridViewRowEventArgs e)
{
If (e. Row. RowType = DataControlRowType. DataRow)
{
E. Row. Attributes. Add ("onmouseover", "if (this! = Oldrow) {currentcolor = this. style. backgroundColor; this. style. backgroundColor = 'peachpuff ', this. style. fontWeight = '';}");
E. Row. Attributes. Add ("onmouseout", "if (this! = Oldrow) {this. style. backgroundColor = currentcolor; this. style. fontWeight = '';}");
E. Row. Attributes. Add ("onclick", e. Row. ClientID. ToString () + ". checked = true; selectx (this )");
}
}