|
查看: 762|回复: 2
|
datagrid當mouseover,如何設從第二個column開始
[复制链接]
|
|
|
以下是我在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

請看我以上的圖片
只有在第一行會發生
在第二行就正常
如何解決呢? |
|
|
|
|
|
|
|
|
|
|
发表于 28-10-2008 07:24 AM
|
显示全部楼层
If you say mouseover for datagrid which start from second column, you can look code below- Dim itemType As ListItemType
- itemType = CType(e.Item.ItemType, ListItemType)
- If (itemType <> ListItemType.Header) Then
- If e.Item.Cells.Count > 0 Then
- For iElement As Integer = 1 To e.Item.Cells.Count - 1
- e.Item.Cells(iElement).Attributes.Add("OnMouseOver", "this.parentNode.style.backgroundColor = '#FFD9A0';")
- e.Item.Cells(iElement).Attributes.Add("OnMouseOut", "this.parentNode.style.backgroundColor = '#FFF';")
- Next
- End If
- 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:- <script language="javascript">
- function GridEffect(ctrl, color)
- {
- for (var i =1; i < ctrl.childNodes.length; i++)
- {
- var childNode = ctrl.childNodes[i];
- childNode.style.backgroundColor = color;
- }
- }
- </script>
复制代码 The javascript put add *.aspx there- Dim itemType As ListItemType
- itemType = CType(e.Item.ItemType, ListItemType)
- If (itemType <> ListItemType.Header) Then
- If e.Item.Cells.Count > 0 Then
- e.Item.Attributes.Add("OnMouseOver", "GridEffect(this, '#FFD9A0');")
- e.Item.Attributes.Add("OnMouseOut", "GridEffect(this, '#FFF');")
- End If
- End If
复制代码 |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|