Protected void gridview1_rowdatabound (Object sender, gridviewroweventargs E)
{
// Mark rows meeting specific conditions as highlighted
If (E. Row. rowtype = datacontrolrowtype. datarow) // determines whether the current row belongs to the datarow type.
{
Int money = convert. toint32 (databinder. eval (E. Row. dataitem, "money"); // obtain the column value of the current row
If (money = 77)
E. Row. backcolor = color. Red;
// String customer = (string) databinder. eval (E. Row. dataitem, "customer ");
String customer = databinder. eval (E. Row. dataitem, "customer"). tostring ();
If (customer = "SDF ")
E. Row. backcolor = color. Red;
}
// Add the highlighted effect of mouse sliding
If (E. Row. rowtype = datacontrolrowtype. datarow) // determines whether the current row belongs to the datarow type.
{
// Save the background color of the current row and add a color when you move the cursor over it.
E. row. attributes. add ("onmouseover", "currentcolor = This. style. backgroundcolor; this. style. backgroundcolor = 'yellow', this. style. fontweight = '';");
// Restore the background color when the mouse leaves
E. Row. Attributes. Add ("onmouseout", "This. style. backgroundcolor = currentcolor, this. style. fontweight = '';");
}
// Click a row to change the background color of the row.
If (E. Row. rowtype = datacontrolrowtype. datarow)
{
E. row. attributes. add ("onclick", "this. style. backgroundcolor = '# 99cc00'; this. style. color = 'buttontext'; this. style. cursor = 'default ';");
}