Để tạo màu nên cho từng dòng khi rê chuột trên GridView các bạn sử dụng sự kiện OnRowDataBound
Tạo chức năng đổi màu nền cho từng dòng khi rê chuột trên GridView
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("style", "background-color: #FFFFFF; color: black;");
e.Row.Attributes.Add("onmouseover", "style.backgroundColor='#FF6600'");
e.Row.Attributes.Add("onmouseout", "style.backgroundColor='#FFFFFF'");
}
}
catch { }
}