Solved

Datagrid onmouseover color change

Posted on 2004-10-27
268 Views
Last Modified: 2012-06-27
Hi...I am working on a webpage using VB.net...i am using a data grid which displays data from SQL table. I am using <AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle> for different colors for alternate rows. Now I want to change the color of the row the mouse is over to some other color say Silver. I am doing this with the following code.
                If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
                    If Not IsNothing(e.Item.DataItem) Then
                        e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#DDEEFF'")
                        e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white'")
                    End If
                End If
The problem is once the mouse leaves the row i am not able to get the previous color of the row. Can someone help me how to get the original color back. Thank You.
0
Question by:niki_kiran
    3 Comments
     
    LVL 18

    Accepted Solution

    by:
    If you're using different color for Alternating Item then you need to Split your function like following

                    If e.Item.ItemType = ListItemType.Item Then
                            e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#DDEEFF'")
                            e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white'")      'Normal Item Color
                    End If
                    If e.Item.ItemType = ListItemType.AlternatingItem Then
                            e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#DDEEFF'")
                            e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='Gainsboro'") 'Alternating Item Color
                    End If

    -tushar
    0
     

    Author Comment

    by:niki_kiran
    thanq
    0
     
    LVL 18

    Expert Comment

    by:tusharashah
    You are welcome :)

    -tushar
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

    846 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now