onmouseover事件
 onmouserover=this.style.backgroundColor='lightgreen'在datagrid中用onitemcereat事件,可以这样做
 e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='lightgreen'")

解决方案 »

  1.   

    在onitemdatabound事件中设置列或行都可以:
    e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'")   ;
    e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='LightSteelBlue'") ; 
    e.Item.Style["cursor"] = "hand";
    e.Item.ForeColor=Color.Blue;
      

  2.   

    谢谢两位,但我不知程序具体书写的格式,比如"onitemdatabound"事件在什么地方设置,能不能描绘一下.
      

  3.   

    谢谢!现在鼠标移动事件已经实现,但是我检查了一下到客户端的数据量加大了,因为每行的<TR
    都带有鼠标事件,能不能象样式表一样定义一个样式,而且当鼠标移动到标题栏时,会将标题栏的颜色发生变化,不可回复,另外我增加一个客户端事件:
    e.Item.Attributes.Add("onclick", "xzst('','','','')") 
    问题是事件所用到的参数是DATAGRID中某列的数据,比如"XH"这一列,怎样将具体的数据传递到事件中,
    谢谢各位,我在线等.
      

  4.   

    String ContractName = DataBinder.Eval(e.Item.DataItem, "ContractName").ToString();
    String ContractID = DataBinder.Eval(e.Item.DataItem, "ContractID").ToString();
          e.Item.Style["cursor"] = "hand";
          e.Item.ToolTip = ContractName;
          e.Item.ForeColor=Color.Blue;
          e.Item.Attributes.Add("onclick","window.open('Details.aspx?ContractID="+ContractID+"','_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,revisable=no,left=100,top=0,width=600,height=550');window.opener=null;window.close();");  
      

  5.   

    xrll() :我贴一段我的程序,请看
    sub databound(sender As Object, e As DataGridItemEventArgs)
            e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'")
            e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='LightSteelBlue'") 
            dim p_xh as string
            p_xh= DataBinder.Eval(e.Item.DataItem, "xh").ToString()
            e.Item.Attributes.Add("onclick","xzst('"+p_xh+"','','','')")
        end sub报错:未将对象引用设置到对象的实例。
    错误行:       p_xh= DataBinder.Eval(e.Item.DataItem, "xh").ToString()
      

  6.   

    xrll() :我想起来,我的DATAGRID中的列是动态生成的,每列只设定了数据源,没有设ID,有没有根据列的序号来设定参数的办法.
      

  7.   

    xrll() :我试过了,设置了ID也报错
      

  8.   

    包括"XH" 
    报错:未将对象引用设置到对象的实例。
    错误行:       p_xh= DataBinder.Eval(e.Item.DataItem, "xh").ToString()