欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp.net Gridview數(shù)據(jù)列中實(shí)現(xiàn)鼠標(biāo)懸浮變色

 更新時(shí)間:2010年06月11日 15:09:07   作者:  
Gridview一般朋友們都比較常用,因?yàn)樗梢苑奖憧旖莸膶?shí)現(xiàn)我們所需的很多功能,代碼也比較簡(jiǎn)潔。平時(shí)的項(xiàng)目中這個(gè)控件我也比較常用,其中有個(gè)功能用到的頻率也比較多。所以記錄下備忘。
功能描述:
在gridview中,鼠標(biāo)在這個(gè)控件的數(shù)據(jù)列表中移動(dòng)時(shí),該列的背景隨鼠標(biāo)的移動(dòng)而改變背景顏色。
功能實(shí)現(xiàn):
在gridview中新增一個(gè)事件RowDataBound,代碼如下:
復(fù)制代碼 代碼如下:

protected void gvwNews_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "color = this.style.backgroundColor;this.style.backgroundColor='#EAFCD5'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=color");
e.Row.Attributes.Add("onclick", "ClickRow()");
}
}

其中的onclick事件是控制選擇行首的復(fù)選框的,點(diǎn)擊行便實(shí)現(xiàn)"點(diǎn)擊"復(fù)選框一樣的效果。代碼如下:
復(fù)制代碼 代碼如下:

function ClickRow()
{
var obj = event.srcElement.parentElement.firstChild.firstChild.tagName;
alert(obj);
if(obj!=null && obj.tagName+""!="undefined")
{
obj.checked=obj.checked ? false : true;
}
}

簡(jiǎn)單的幾行代碼所需功能就可以實(shí)現(xiàn)了。

相關(guān)文章

最新評(píng)論