在gridview里实现鼠标划过行效果
注意:一下代码要写在RowDataBound事件中
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='#E066FF'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
((LinkButton)(e.Row.Cells[5].Controls[0])).Attributes.Add("onclick", "return confirm('是否真的要删除数据!')");
Button xiugai = (Button)(e.Row.FindControl("xiugai")); //"xiugai"为按钮的ID
xiugai.Attributes.Add("onclick", "xiugai(" + e.Row.Cells[1].Text + ")");
}
}