473,395 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

GridView onmouseout problem



Hi,

I was using the datagrid and am now starting to use the gridview in
asp.net 2.0. I used to use the first below sub for when i would
mouseover a row - this highlighted the row but did not affect the
original colour of the datagrid on mouseout. My datagrid uses
alternating row colours. However when i try and amend the code for the
gridview - when i do a onmouseout all rows now go to a white backgound
and the alternating colours in the rows disappear.

The first sub shows the code that works in my datagrid and the second
sub shows the code that i have amended for my gridview so far but will
not work.

Can anyone see what i am doing wrong.

Thanks.

------------------------------------------------------------

Private Sub dgComments_ItemDataBound(ByVal sender As System.Object,
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgComments.ItemDataBound

Dim dv As DataView = dgComments.DataSource
Dim dcCol As DataColumn
Dim dc As DataColumnCollection = dv.Table.Columns
Dim strID As String

For Each dcCol In dv.Table.Columns
If e.Item.ItemType = ListItemType.AlternatingItem Or
e.Item.ItemType = ListItemType.Item Then

strID = dgComments.DataKeys(e.Item.ItemIndex)

'To change the color of the row onMouseOver in the
Datagrid
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='#fef5d1'")
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='#ffffff'")

End If
Next

End Sub

---------------------------------------------------

Private Sub gvUser_ItemDataBound(ByVal sender As System.Object, ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
gvUser.RowDataBound

Dim dv As Data.DataView = gvUser.DataSource
Dim dcCol As Data.DataColumn
Dim dc As Data.DataColumnCollection = dv.Table.Columns
Dim strID As String

For Each dcCol In dv.Table.Columns
If e.Row.RowType = ListItemType.AlternatingItem Or
e.Row.RowType = ListItemType.Item Then

strID =
gvUser.DataKeys(e.Row.DataItemIndex).Value.ToStrin g

'To change the color of the row onMouseOver in the
GridView
e.Row.Attributes.Add("onmouseover",
"this.style.backgroundColor='#fef5d1'")
e.Row.Attributes.Add("onmouseout",
"this.style.backgroundColor='#ffffff'")

End If
Next
End Sub

Mar 29 '06 #1
0 1746

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rob Roberts | last post by:
I am trying to figure out a way to add onmouseover and onmouseout events to ButtonFields in a GridView in order to give them a rollover effect, but so far I haven't been able to figure out a way to...
3
by: Rob Roberts | last post by:
Is there any way to add attributes to GridView ButtonFields? I'm looking for a way to add event handlers to ButtonFields. With regular ASP.NET buttons, I can add event handlers by using the...
6
by: InK_ | last post by:
Hi, All! I need to accomplish such functionality: A data row should be highlighted with the other color if cursor is over it. I also have the old code from asp which uses <tr...
4
by: BiffMaGriff | last post by:
Hello, I have a GridView that I put inside an update panel. I have a control that attaches to the datasource of the gridview that filters the data, databinds the gridview and then updates the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.