Secret sauce for Nice Looking GridView

Here is the ingredients for making the Datagrid view have a nice mouse rollover to change colors.

[code:c#]

protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        e.Row.Attributes.Add(“onmouseover”, “this.style.cursor=’pointer’;this.originalstyle=this.style.backgroundColor;this.style.backgroundColor=’#EEFF00′”);
        e.Row.Attributes.Add(“onmouseout”,”this.style.backgroundColor=this.originalstyle;”);
        e.Row.Attributes[“onclick”] = ClientScript.GetPostBackClientHyperlink(this.gv, “Select$” + e.Row.RowIndex);
    }
}

[/code]

So yellow when the mouse is pointing at the row then back to whatever it was before the mouse was when the mouse leaves.

 

Comments

comments

0

Leave a Reply