在DataGrid_ItemDataBound()事件中,
e.Item.Attributes.Add("onmouseover","设置不同的颜色")

解决方案 »

  1.   


    foreach(DataGridItem item in grd1.Items )
    {
    for(int i=1;i<grd1.Columns.Count;i++)
    {
    item.Cells[i].Attributes.Add("Style","cursor:hand;");
    }
    item.Cells[1].Attributes.Add("onclick","window.returnValue='"+item.Cells[1].Text+"';"+"self.close();");
    item.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#b7c4e2'");
    item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor");

    }
    }
      

  2.   

    var ParentObj = null;
    function document.onclick()
    {
    var ObjTable = document.all.DataGrid1;
    if(ObjTable.contains(event.srcElement) == true)
    {
    if(ParentObj != null)
    {
    ParentObj.style.color = '000000';
    }
    var ThisObj = event.srcElement.parentNode;
    while(ThisObj.tagName != "TR") ThisObj = ThisObj.parentNode;
    ThisObj.style.color = 'FF0000';
    ParentObj = ThisObj;
    }
    }
      

  3.   

    e.Item.Attributes.Add("onmouseover","this.bgColor='#EEEEEE'" );e.Item.Attributes.Add("onmouseover","#EEEEEE" );这几种方法我都试了,不行呀?
      

  4.   

    http://dotnet.aspx.cc/Exam/DragableXpStyleTable/DragableXpStyleTable.aspxhttp://xml.sz.luohuedu.net/xml/ShowDetail.asp?id=E5254FD8-252F-457C-F61E-32EE353E8BF2
      

  5.   

    Private Sub myDataGrid_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles myDataGrid.ItemDataBound
      e.Item.Attributes.Add("onmouseover", "this.setAttribute('BKC',this.style.backgroundColor); this.style.cursor='hand';this.style.backgroundColor='#dddddd'")
      e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=this.getAttribute('BKC');")
    end sub
      

  6.   

    hsb0307(hsb8704066) 
     
      http://dotnet.aspx.cc/Exam/DragableXpStyleTable/DragableXpStyleTable.aspx我看了这个xp效果的了,有知道如何能让这个datagrid显示表格线么?