5 February 2014

Gridview row color change using RowDataBound event

 If you want to change the gridview row color change on mouse over and mouse out then write the below code in rowdatabound event.

protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "self.MouseOverOldColor=this.style.backgroundColor;this.style.backgroundColor='#C0C0C0'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=self.MouseOverOldColor");
            }
        }

No comments:

Post a Comment