1. design the style sheet as needed. I will give it a general one here.
<PRE>. button_down
{}{
Color: red;
Border: Inset 2px;
}
. Button_up
{}{
Color: black;
Border: outset 2px;
}
. Alt_row_highlight
{}{
Background-color: yellow;
}
. Alt_row_nohighlight
{}{
Background-color: white;
}
. Row_highlight
{}{
Background-color: cyan;
}
. Row_nohighlight
{}{
Background-color: white;
}
</PRE>
2. javascript: Here, we mainly use JS's excellent performance on the client, so that JS can dynamically change the item style of the DataGrid to achieve the highlighted effect. Function classchange (stylechange, item)
{
Item. classname = stylechange;
}
3. The final step is to add the private void datagrid1_itemcreated (Object sender, system. Web. UI. webcontrols. datagriditemeventargs E) to the items of the DataGrid)
{
If (E. Item. itemtype = listitemtype. item)
{
E. Item. Attributes. Add ("onmouseover", "classchange ('row _ highlight ', this );");
E. Item. Attributes. Add ("onmouseout", "classchange ('row _ nohighlight ', this );");
}
}