DataGrid [onmouseover] [onmouseout]

private void mygrid_ItemDataBound(object sender, System.Web.UI.Webcontrols.DataGridItemEventArgs e){
        if(e.Item.ItemType == ListItem.AlternatingItem || e.Item.ItemType == ListItem.Item){
         //设置每一行的背景颜色的变化
                e.Item.Attributes.Add("onmouseover", "this.oldcolor = this.style.backgroundcolor; this.style.backgroundcolor = '#336699'");
                e.Item.Attributes.Add("onmouseout", "this.oldcolor = this.style.backgroundcolor");
                //设置单元格的颜色变化
                for(int i = 0; i < mygrid.columns.count, i ++){
                       e.Items.Cell[i].Attributes.Add("onmouseover","somthing");
                       e.Items.Cell[i].Attributes.Add("onmouseout", "something");
                }
}



你可能感兴趣的:(UI,Web)