- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- //判断当前行是否是数据行
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- //设置每一行的onmouseover和onmouseout属性
- //e.Row.Attributes.Add("onmouseover", "over(this)");
- //e.Row.Attributes.Add("onmouseout", "out(this)");
- e.Row.Attributes.Add("onmouseover", "defaultColor = this.style.backgroundColor;this.style.backgroundColor = 'red';");
- e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor = defaultColor;");
- }
- }
コードをコピーします
上記のjsスクリプトをメソッドに書き込むこともでき、呼び出すのがより便利です
|