Function Description:
In the gridview, when the mouse moves in the data list of this control, the background of this column changes the background color as the mouse moves.
Function implementation:
Add an event RowDataBound in the gridview. The Code is as follows:
Copy codeThe Code is as follows:
Protected void gvwNews_RowDataBound (object sender, GridViewRowEventArgs e)
{
If (e. Row. RowType = DataControlRowType. DataRow)
{
E. Row. Attributes. Add ("onmouseover", "color = this. style. backgroundColor; this. style. backgroundColor = '# EAFCD5 '");
E. Row. Attributes. Add ("onmouseout", "this. style. backgroundColor = color ");
E. Row. Attributes. Add ("onclick", "ClickRow ()");
}
}
The onclick event controls the check box at the beginning of a row. Click the row to achieve the same effect as the "click" check box. The Code is as follows:
Copy codeThe Code is as follows:
Function ClickRow ()
{
Var obj = event. srcElement. parentElement. firstChild. firstChild. tagName;
Alert (obj );
If (obj! = Null & obj. tagName + ""! = "Undefined ")
{
Obj. checked = obj. checked? False: true;
}
}
A few simple lines of code are required.