2.0 for the GridView add a mouse-sliding row color highlighting effect

Source: Internet
Author: User
Tags eval

protected void GridView1_RowDataBound (object sender, GridViewRowEventArgs e)
//To mark rows that meet specific criteria as highlighted
if (E.row.rowtype = = Datacontrolrowtype.datarow)//Determines whether the current row belongs to the DataRow type of the row
int money = Convert.toint3 2 (DataBinder.Eval (E.row.dataitem, "money");//Fetch the column value of the current row
if (money = =)
E.row.backcolor =;< br>//string customer = (string) DataBinder.Eval (E.row.dataitem, "customer");
String customer = DataBinder.Eval (E.row.dataitem, "customer"). ToString ();     
if (customer = = "SDF")
E.row.backcolor =;
//Add the mouse-over highlighting
if (E.row.rowtype = = Datacontrolrowtype.datarow)//Determines whether the current row is of the DataRow type
When the mouse is put up, first save the background color of the current row and attach a color to the
E.row.attributes.add ("onmouseover", ";th ' Yellow ', '; ');
//The previous color of the background color restored when the mouse is left
E.row.attributes.add ("onmouseout", ", ';");
//Click to change the row background color
if (E.row.rowtype = Datacontrolrowtype.datarow)
E.row.attribu Tes. ADD ("onclick", " ' #99cc00 '; ' buttontext '; ' default ';");

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.