例如:
protected void gvEmployeeBase_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.Header && e.Row.RowType != DataControlRowType.Footer)
{
if (e.Row.RowIndex >= 0)
{
if(e.Row.Cells[7].Text=="0")
{
e.Row.Cells[7].Text="不存在";
}
if(e.Row.Cells[7].Text=="1")
{
e.Row.Cells[7].Text="存在";
}
//添加自定義屬性,當鼠標移過來時設置該行的背景色為"#EBEBED",並保存原背景色
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#EBEBED'");
//添加自定義屬性,當鼠標移走時還原該行的背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
}
}
}