给你个思路:for each tablerow in dataGrid.items   tablerow.attributes.item("Onclick")="this.bgcolor=red"next

解决方案 »

  1.   

    e.Item.Attributes.Add("onkeypress", "this.style.backgroundColor='color'")
      

  2.   

    在DataGrid1_ItemCreated事件中:
    e.Item.Attributes.Add
    ("onclick","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#FFFFCC'");
    //e.Item.Attributes.Add
    //("onmouseout","this.style.backgroundColor=currentcolor");
      

  3.   

    '使鼠标移过时背景色跟着变
                If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
                    e.Item.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#FFFFC0'")
                    e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor")
                End If