In ASP. NET, the style changes when the mouse slides over the gridview and when the mouse is clicked.Code:
// 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 to it.
E. Row. Attributes. Add ( " Onmouseover " , " Currentcolor = This. style. backgroundcolor; this. style. backgroundcolor = 'yellow', 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 = ''; " );
}
// 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 '; " );
}