Asp.Net GridView in highlighting the effect of adding mouse over and click on the line color change

void GridView1_RowDataBound protected (Object SENDER, GridViewRowEventArgs E)
{
// adapted mouse after color
if (e.Row.RowType == DataControlRowType.DataRow) // determines whether the current row of the line type datarow
{

// When the mouse put up when the first save background color of the current line and attached to a color

e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='yellow',this.style.fontWeight='';");

// When the mouse leaves the background color to restore the previous color

e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
}


//单击行改变行背景颜色
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "this.style.backgroundColor='#99cc00'; this.style.color='buttontext';this.style.cursor='default';");
}
}

Guess you like

Origin www.cnblogs.com/ljs-13/p/12173184.html