Solved

Datagrid - how to highlight rows with mouseover

Posted on 2003-10-22
3
380 Views
Last Modified: 2010-04-16
Anyone know how to use the onmouseover event to get the rows to highlight in a datagrid?  
0
Comment
Question by:marmar111
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Expert Comment

by:jlach
ID: 9600866
The way to do this is prolly to capture the mouse move event on the data grid, then get the location of the mouse relative to the grid, then go ahead and write a routine to get the row that is at the location of the mouse...
0
 
LVL 8

Expert Comment

by:gregasm
ID: 10464972
Try to capture the onMouseOver event of the DataGridTextBoxColumn.
0
 
LVL 3

Accepted Solution

by:
nhewitt21 earned 20 total points
ID: 11591533
I used the OnItemCreated in my datagrid to do this for one of my webprojects:

For example:
OnItemCreated="List_DataGrid_ItemCreated"

Then in your codebehind (C#):
protected void ListNews_DataGrid_ItemCreated(Object sender, DataGridItemEventArgs e)
{
      DataGridItem myItem = e.Item;
      switch (myItem.ItemType)
      {
            case ListItemType.Item:
                  myItem.Attributes.Add("onmouseover", "this.style.backgroundColor=\"#FFD3D3\"");
                  myItem.Attributes.Add("onmouseout", "this.style.backgroundColor=\"#D9D9D9\"");
                  break;
            case ListItemType.AlternatingItem:
                  myItem.Attributes.Add("onmouseover", "this.style.backgroundColor=\"#FFD3D3\"");
                  myItem.Attributes.Add("onmouseout", "this.style.backgroundColor=\"#E9E9E9\"");
                  break;
            default:
                  break;
      }
}

Job Done.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 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