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 = ''; " );
}
}