C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ASP.NET GridView »

Dynamically changing row color on mouse over and mouse out


Posted Date: 12 Nov 2008    Resource Type: Code Snippets    Category: ASP.NET GridView
Author: Gnana Prakash Member Level: Gold    
Rating: 1 out of 5Points: 5



If you want to change Row color on dynamically when mouse over and mouse out, you can use below code in Row Created event.

CSS Code
--------------


.normalrow
{
background-color:white;
}
.hightlighrow
{
background-color:#cccccc;
}




Code Behind Code
--------------------------



Protected Sub gvDynamicRowcolor_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvDynamicRowcolor.RowCreated
If (e.Row.RowType = DataControlRowType.DataRow) Then
e.Row.Attributes.Add("onmouseover", "this.className='hightlighrow'")
e.Row.Attributes.Add("onmouseout", "this.className='normalrow'")
End If
End Sub





Responses

Author: Lizzy    13 Nov 2008Member Level: Bronze   Points : 1
How do you make a particular row to highlight a color on click? It should not be changed onmouseover or onmouseout.


Author: Gnana Prakash     14 Nov 2008Member Level: Gold   Points : 1
Hi Lizzy

just you can add below code

e.Row.Attributes.Add("onclick", "this.className='classname'");




Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Dynamically changing row color on mouse over and mouse out  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Merging Grid View Header
Previous Resource: Working with XML in a Datagrid and LoginPage
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET GridView


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use