佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 762|回复: 2

datagrid當mouseover,如何設從第二個column開始

[复制链接]
发表于 26-10-2008 08:42 AM | 显示全部楼层 |阅读模式
以下是我在ItemCreated中寫的程式
  
         Dim itemType As ListItemType
         itemType = CType(e.Item.ItemType, ListItemType)
         If (itemType <> ListItemType.Header) Then
             If (itemType <> ListItemType.AlternatingItem) Then
                 e.Item.Attributes.Add("OnMouseOver", "this.style.backgroundColor = '#FFD9A0';")
                 e.Item.Attributes.Add("OnMouseOut", "this.style.backgroundColor = 'white';")
             Else
                 e.Item.Attributes.Add("OnMouseOver", "this.style.backgroundColor = '#FFD9A0';")
                 e.Item.Attributes.Add("OnMouseOut", "this.style.backgroundColor = 'white';")
             End If
         End If




請看我以上的圖片
只有在第一行會發生
在第二行就正常
如何解決呢?
回复

使用道具 举报


ADVERTISEMENT

发表于 28-10-2008 07:24 AM | 显示全部楼层
If you say mouseover for datagrid which start from second column, you can look code below
  1.         Dim itemType As ListItemType
  2.         itemType = CType(e.Item.ItemType, ListItemType)
  3.         If (itemType <> ListItemType.Header) Then
  4.             If e.Item.Cells.Count > 0 Then
  5.                 For iElement As Integer = 1 To e.Item.Cells.Count - 1
  6.                     e.Item.Cells(iElement).Attributes.Add("OnMouseOver", "this.parentNode.style.backgroundColor = '#FFD9A0';")
  7.                     e.Item.Cells(iElement).Attributes.Add("OnMouseOut", "this.parentNode.style.backgroundColor = '#FFF';")
  8.                 Next
  9.             End If
  10.         End If
复制代码
Hope the code which is you desired.

Thank you
回复

使用道具 举报

发表于 28-10-2008 07:47 AM | 显示全部楼层
If you want to point the row and the color effect start from second column please see the code below:
  1.                <script language="javascript">
  2.                         function GridEffect(ctrl, color)
  3.                         {
  4.                                 for (var i =1; i < ctrl.childNodes.length; i++)
  5.                                 {
  6.                                         var childNode = ctrl.childNodes[i];
  7.                                         childNode.style.backgroundColor = color;
  8.                                 }
  9.                         }
  10.                 </script>
复制代码
The javascript put add *.aspx there
  1.         Dim itemType As ListItemType
  2.         itemType = CType(e.Item.ItemType, ListItemType)
  3.         If (itemType <> ListItemType.Header) Then
  4.             If e.Item.Cells.Count > 0 Then
  5.                 e.Item.Attributes.Add("OnMouseOver", "GridEffect(this, '#FFD9A0');")
  6.                 e.Item.Attributes.Add("OnMouseOut", "GridEffect(this, '#FFF');")
  7.             End If
  8.         End If
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 22-12-2025 07:22 AM , Processed in 0.108256 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表