Solved

Datagrid - how to highlight rows with mouseover

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

746 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

12 Experts available now in Live!

Get 1:1 Help Now