Javascript controls the style of data window rows

Source: Internet
Author: User

<Style type = "text/CSS">
TD. bgstyle {border-top: #215dc6 1px solid; filter: progid: DXImageTransform. microsoft. gradient (gradienttype = 0, startcolorstr = # c7d4f7, endcolorstr = # ffffff); color: #215dc6; border-bottom: #215dc6 1px solid; Background-color: # e6e6e6}
TD. bgstyleleft {border-top: #215dc6 1px solid; filter: progid: DXImageTransform. microsoft. gradient (gradienttype = 0, startcolorstr = # Strong, endcolorstr = # ffffff); border-left: #215dc6 1px solid; color: #215dc6; border-bottom: #215dc6 1px solid; background-color: # e6e6e6}
TD. bgstyleright {border-Right: #215dc6 1px solid; border-top: #215dc6 1px solid; filter: progid: DXImageTransform. microsoft. gradient (gradienttype = 0, startcolorstr = # c7d4f7, endcolorstr = # ffffff); color: #215dc6; border-bottom: #215dc6 1px solid; Background-color: # e6e6e6}
</Style>
<Script language = "JavaScript">
<! --
Function changein (object)
{
Object. cells [0]. classname = "bgstyleleft ";
Count = object. cells. length;
For (I = 1; I <= count-1; I ++)
{
Object. cells [I]. classname = "bgstyle ";
}
Object. cells [count-1]. classname = "bgstyleright ";
// Document. All ("tblhisname"). innertext = "aaaa ";
// Document. All. tblhisname. value = object. cells [0]. value;
}
// -->
</SCRIPT>
<Script language = "JavaScript">
<! --
Function changeout (object)
{
Object. cells [0]. classname = "";
Count = object. cells. length;
For (I = 1; I <= count-1; I ++)
{
Object. cells [I]. classname = "";
}
Object. cells [count-1]. classname = "";
}
// -->
</SCRIPT>

Private void maid (Object sender, system. Web. UI. webcontrols. datagriditemeventargs E)
{
If (E. Item. itemtype = listitemtype. Item | E. Item. itemtype = listitemtype. alternatingitem)

{

String orderitemid = E. Item. cells [0]. Text; // E. Item. cells [0]. text;
Tblhisname. Text = orderitemid;
// Add Custom Attributes. When the mouse moves over, set the background color of the row to "6699ff" and save the original background color.
E. Item. Attributes. Add ("onmouseover", "currentcolor = This. style. backgroundcolor; this. style. backgroundcolor = '# 6699ff '");
// Add custom attributes to restore the background color of the row when the mouse moves
E. Item. Attributes. Add ("onmouseout", "This. style. backgroundcolor = currentcolor ");

// Mouseover highlighting
E. Item. Attributes. Add ("onmouseover", "changein (this )");
E. Item. Attributes. Add ("onmouseout", "changeout (this )");
E. Item. Attributes. Add ("onclick", "window. Open ('default. aspx? Id = "+ E. Item. cells [0]. Text + "');");

 

}

If (E. Item. itemindex! =-1)
{
E. Item. Attributes. Add ("onmouseover", "This. bgcolor = '# c1d2ee '");
E. item. attributes. add ("onclick", "document. all. text1.innertext = This. cells [0]. innertext; document. all. form1.city. value = This. cells [0]. innertext ;");
If (E. Item. itemindex % 2 = 0)
{
E. Item. Attributes. Add ("bgcolor", "# ffffff ");
E. Item. Attributes. Add ("onmouseout", "This. bgcolor = Document. getelementbyid ('ngin1'). getattribute ('singlevalue ')");
}
Else {
E. Item. Attributes. Add ("bgcolor", "oldlace ");
E. Item. Attributes. Add ("onmouseout", "This. bgcolor = Document. getelementbyid ('hand1'). getattribute ('oldvalue ')");
}
} Else
{
Datagrid1.attributes. Add ("oldvalue", "oldlace ");
Datagrid1.attributes. Add ("singlevalue", "# ffffff ");
}
}
# Region web form designer generated codeoverride protected void oninit (eventargs E)
{/// Codegen: This call is required by the ASP. NET web form designer. // Initializecomponent (); base. oninit (E );}



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.