鼠标悬停前读取gridview的行背景色 [英] read row backcolor of gridview before mouseover
本文介绍了鼠标悬停前读取gridview的行背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在将鼠标悬停和将鼠标移出gridvierw行的先前颜色的同时更改gridview行的背景颜色.
I want to change backcolor of gridview row while mouseover and mouseout previous color of gridvierw row.
推荐答案
对同一事件使用RowDataBound
事件. >
试试:
UseRowDataBound
event for the same.
Try:
// This will be called for every row bind
protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
// Creating hover effects on mouseover event
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "this.style.backgroundColor='#A1AAF0';";
// OR this way
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#A1AAF0';");
// OR this way
e.Row.Attributes.Add("onmouseover", "this.className='highlightRow'");
}
}
这篇关于鼠标悬停前读取gridview的行背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文