Color Display of gridview (color display that meets specific data requirements, and mouse event Color Display)

Source: Internet
Author: User
We can process the display of related colors in the rowdatabound event of the gridview! Easy to read Code You can understand it!   Protected   Void Gridview1_rowdatabound ( Object Sender, gridviewroweventargs E)
{
If (E. Row. rowtype = Datacontrolrowtype. datarow)
{
String Str = Convert. tostring (databinder. eval (E. Row. dataitem, " Username " ));
// Display different colors for Data meeting specific requirements
If (Str = " Duoduo " )
{
E. Row. backcolor = System. Drawing. color. Beige;
}
E. Row. cells [ 1 ]. Text =   " <I> "   + E. Row. cells [ 1 ]. Text +   " </I> " ;
// Different colors are displayed when the mouse passes or leaves.
E. Row. Attributes. Add ( " Onmouseover " , " Currentcolor = This. style. backgroundcolor; this. style. backgroundcolor = 'red', this. style. fontweight = ''; " );
// When the mouse leaves, the background color is restored to the previous color.
E. Row. Attributes. Add ( " Onmouseout " , " This. style. backgroundcolor = currentcolor, this. style. fontweight = ''; " );

}
}

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: info-contact@alibabacloud.com 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.