This article is a mirror article of machine translation, please click here to jump to the original article.

View: 16994|Reply: 0

[ASP.NET] asp.net have the GridView highlight the selected rows and set the selected rows to be highlighted

[Copy link]
Posted on 6/24/2015 10:10:54 AM | | |
  1. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  2.         {
  3.             //判断当前行是否是数据行
  4.             if (e.Row.RowType == DataControlRowType.DataRow)
  5.             {
  6.                 //设置每一行的onmouseover和onmouseout属性
  7.                 //e.Row.Attributes.Add("onmouseover", "over(this)");
  8.                 //e.Row.Attributes.Add("onmouseout", "out(this)");
  9.                 e.Row.Attributes.Add("onmouseover", "defaultColor = this.style.backgroundColor;this.style.backgroundColor = 'red';");
  10.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor = defaultColor;");
  11.             }
  12.         }
Copy code



You can also write the above js script into a method, which is more convenient to call




Previous:I would like to ask the webmaster if he has applied for the school's entrepreneurship subsidy
Next:Similarities and differences between DeleteOnSubmit and DeleteAllOnSubmit
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com