Solved

Datagrid - how to highlight rows with mouseover

Posted on 2003-10-22
3
368 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

816 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