//JS脚本 function showHistogram() { //获取GridView控件 var gdview=document.getElementById("<%=gvwDayRain.ClientID %>"); if(gdview == null) return; selectedRow = gdview.rows(1); c=selectedRow.style.backgroundColor; selectedRow.style.backgroundColor ="#77aa00"; } //页面控件及JS脚本方法调用 <body οnlοad="showHistogram()"> <asp:GridView ID="gvwDayRain" runat="server" OnRowDataBound="gvwDayRain_RowDataBound" > //后台代码: /// <summary> /// 行点击事件柱状图显示 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvwDayRain_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor; this.style.backgroundColor='#6699ff'"); e.Row.Attributes.Add("onmouseout", "if(this.style.backgroundColor == '#6699ff') this.style.backgroundColor=c"); } }