protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType != DataControlRowType.DataRow) return; Label lb = (Label)e.Row.FindControl("Label2"); //lb.Attributes["ondblclick"] = "return lbClick()"; lb.Attributes.Add("ondblclick", "SelectRow(" + e.Row.RowIndex + ")"); lb.Attributes.Add("onmouseover", "this.style.cursor='hand'"); lb.Attributes.Add("onmouseout", "this.style.cursor=''"); Label lb3 = (Label)e.Row.FindControl("Label3"); //lb3.Attributes["ondblclick"] = "return lbClick()"; lb3.Attributes.Add("ondblclick", "SelectRow(" + e.Row.RowIndex + ")"); lb3.Attributes.Add("onmouseover", "this.style.cursor='hand'"); lb3.Attributes.Add("onmouseout", "this.style.cursor=''"); //当鼠标放上去的时候 先保存当前行的背景颜色 并给附一颜色 e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#BFEFFF'"); //当鼠标离开的时候 将背景颜色还原的以前的颜色 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=''"); }