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;");
}
}
{
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)");
}
}