您的位置:首页 > 其它

GridView鼠标移动到哪行,哪行的背景色改变

2015-08-18 14:43 197 查看
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

{

if (e.Row.RowType == DataControlRowType.DataRow)

{

e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#ffcc33'");

e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");





protected void gridList_RowDataBound(object sender, GridViewRowEventArgs e)
{

//如果是绑定数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//鼠标经过时,行背景色变
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E6F5FA'");
//鼠标移出时,行背景色变
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
//行事件,千万不要写循环,本身ROWDATABOUND就是循环的
e.Row.Attributes.Add("dbclick", "可直接写JS代码也可写JS函数,然后前台设置JS函数");
//列事件,可以循环实现多列
e.Row.Cells[1].Attributes.Add("onclick", "showedit(this)");
e.Row.Cells[3].Attributes.Add("onclick", "showedit(this)");
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: