ASP.NET - GridView光棒效果
GridView光棒效果
protected void GV_Query_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow) //判定row的型態是資料行
{ e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#80FFFF';"); //滑鼠移到變色
if (e.Row.RowState == DataControlRowState.Alternate)
{ e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='MintCream';"); //滑鼠移開底色恢復為MintCream }
else
{ e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='LightYellow';"); //滑鼠移開底色恢復為LightYellow
}
}
}

















