实现功能:鼠标经过,GridView行变色。代码如下:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { DataRowView dv = (DataRowView)e.Row.DataItem; if (e.Row.RowType == DataControlRowType.DataRow) { string str = @"javascript:window.open('Detail.aspx?id=" + dv.Row["Id"].ToString() + "');"; e.Row.Attributes.Add("onclick", str); e.Row.Attributes.Add("style", "cursor:hand"); e.Row.Attributes.Add("onmouseover", "OldStyle=this.style.backgroundColor;this.style.backgroundColor='#f4f1cc';"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=OldStyle"); } }