|
-
Mar 6th, 2009, 12:50 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] Gridview row color change on mouseover
I migrated this code from vs 03 to vs 05.
It work fine in 03 but not 05.
note : the code below is 05 which is modified.
When I execute code below in my vs 05 the row color has changed but when mouseout from row the color will change back to only 1 type of color.
Can any one figure out my wrong ?
asp Code:
Protected Sub grdStatusMaster_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdStatusMaster.RowDataBound
If e.Row.RowType = ListItemType.Item Or e.Row.RowType = ListItemType.AlternatingItem Then
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='ghostwhite'")
If e.Row.RowType = ListItemType.Item Then
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='WhiteSmoke'")
Else
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='White'")
End If
End If
End Sub
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Mar 6th, 2009, 02:10 AM
#2
Re: [2005] Gridview row color change on mouseover
You are using the wrong Enum for comparison with the RowType property. It is one of the DataControlRowType values which indicate if the Row is a Header, Data, Footer etc.
Use the Row.RowState property to check for the Alternate Row.
Code:
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='ghostwhite'")
If (e.Row.RowState And DataControlRowState.Alternate) = DataControlRowState.Alternate Then
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='WhiteSmoke'")
Else
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='White'")
End If
End If
End Sub
-
Mar 6th, 2009, 03:08 AM
#3
Thread Starter
Hyperactive Member
Re: [2005] Gridview row color change on mouseover
Thanks your help bruve.
I solved the problem by using your code.
vBulletin Message
You must spread some Reputation around before giving it to brucevde again.
How to spread the reputation ?
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Mar 10th, 2009, 02:22 AM
#4
Re: [RESOLVED] [2005] Gridview row color change on mouseover
Give reputation to a few other people, then come back and give it to bruce.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|