Click here to Skip to main content
15,908,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm working with gridview using skin and it has different alternate color .

I want to change the color on mouseover and return to original color on onmouseout.
How should I do it?
Posted
Updated 26-Apr-10 22:14pm
v3

You can add code on GridView OnRowCreated Event like :

C#
if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.RowState == DataControlRowState.Alternate)
            {
                e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor=MouseOvercolor;");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=MouseOutColor;");
            }
            else
            {
                e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor=MouseOverColor;");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=MouseOutColor;");
            }
        }
 
Share this answer
 
step 1: create a script in .aspx form


function MouseOver()
{
document.getElementById('gvComputeTax').style.backgroundColor = "Blue";
}
function MouseOut()
{
document.getElementById('gvComputeTax').style.backgroundColor = "Black";
}


step 2: call the function in grid view like-

<asp:gridview id="gvComputeTax" runat="server" autogeneratecolumns="False" gridlines="None"
="" backcolor="White" bordercolor="White" borderstyle="Ridge" borderwidth="1px" cellspacing="1" onmouseover="MouseOver();" onmouseout="MouseOut();">



Mahesh Patel
vipsha16@yahoo.com
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900