//DataGrid样式:
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) {
if (e.Item.ItemType!=ListItemType.Header){
e.Item.Attributes.Add("onmouseover", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#C8F7FF'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor");
e.Item.Attributes.Add("onclick","this.style.backgroundColor='red';this.style.cursor='hand';");
}
}
//DataList样式:
在DataList的ItemTemplate里写入一个表,其中tr设置如下
<TR οnmοuseοver="this.style.backgroundColor='#FFFFFF'" οnmοuseοut="this.style.backgroundColor=''">