[DataGrid] [sorting] using JavaScript + CSS + DataGrid to highlight items

Source: Internet
Author: User
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 );");
}
}

Related Article

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.