復制代碼 代碼如下:
protected void EditGridview_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType== DataControlRowType.DataRow)
{
//當鼠標放上去的時候 先保存當前行的背景顏色 并給附一顏色
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='inactivecaptiontext',this.style.fontWeight='';this.style.cursor='hand';");
//當鼠標離開的時候 將背景顏色還原的以前的顏色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
//當鼠標單擊時,加深色標志
e.Row.Attributes.Add("onclick", "setvalue();if(window.oldtr!=null){window.oldtr.runtimeStyle.cssText='';}this.runtimeStyle.cssText='background-color:#e6c5fc';window.oldtr=this");
}
}
復制代碼 代碼如下:
<script type="text/javascript" >
function setvalue() {
alert('行單擊事件,同時變色');
}
</script>
新聞熱點
疑難解答
圖片精選