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
Solved

Datagrid - how to highlight rows with mouseover

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

839 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