Click here to Skip to main content
15,916,693 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello experts,

am facing problem with gridview rows with mouse over.

already i have a color for one column--- cell[0]..

again when i mouseover on row , i want to change the color for complete row.

this is my code.

C#
protected void GVUsers_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        foreach (GridViewRow item in GVLoginHistory.Rows)
        {
            item.Cells[0].BackColor = Color.FromName("#54e4b8");
        }

        if (e.Row.RowType == DataControlRowType.DataRow)
        {


            e.Row.Attributes.Add("onmouseover",
            "this.originalcolor=this.style.backgroundColor;" + " this.style.backgroundColor='#FDCB0A';");

            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalcolor;");

        }
    }



Please help, thanks in advance.
Posted

1 solution

Please check the below article and answer. It will give you exactly what you want.

1. Highlight asp.net gridview rows on mouseover - out using JavaScript [^].
2. highlight a particular row in a gridview on MouseOver[^].
 
Share this answer
 
Comments
Software Engineer 892 26-May-13 6:57am    
hello boss, its working for me, but the problem is ........i already have back color on first column.

again when i mouse over, the color should effect the complete row including first column also.

Please help.
Then again change that backcolor for that column when you are doing it for the entire row.

I mean inside the if clause do something like below.

if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].BackColor = Color.FromName("#FDCB0A");

// then your other code to apply back color to the row.
}

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