Apply the color of the girdview mouse to all pages and select all the clients.

Source: Internet
Author: User

Write a common JS Function

Code

  Function  Gridviewcolor (gridviewid ){
// Obtain all rows to be controlled
VaR Allrows = Document. getelementbyid (gridviewid );
If (Allrows ! = Null ){
Allrows = Allrows. getelementsbytagname ( " Tr " );

// Set the background color and events of each row. The cycle starts from 1 instead of 0. You can avoid the row in the header.
For ( VaR I = 1 ; I < Allrows. length; I ++ ){
Allrows [I]. onmouseout = Function (){ This . Style. Background = " # Ffffff " ;}
}
}
}

To reference this JavaScript code, you only need to register it in page_load on each page. ctl00_pagebody_gvitems is the Client ID of girdview. 

  Scriptmanager. registerstartupscript (This. Page,This. GetType (),"JS","Gridviewcolor ('ctl00 _ pagebody_gvitems ');",True);

All selectedCode:

  <  Script  Type  = "Text/JavaScript"  >  
Function Checkall (ocheckbox)
{
VaR Gvitems = Document. getelementbyid ( " <% = Gvitems. clientid %> " );
For (I = 1 ; I < Gvitems. Rows. length; I ++ )
{
Gvitems. Rows [I]. cells [ 0 ]. Getelementsbytagname ( " Input " )[ 0 ]. Checked = Ocheckbox. checked;
}
}
</ Script >
< ASP: gridview ID = "Gvitems" Runat = "Server" >   < Columns >
< ASP: templatefield Headertext = "Option" >
< Headertemplate >
< ASP: checkbox ID = "Checkbox1" Runat = "Server" Text = "Select all" Autopostback = "True" Onclick = "Checkall (this )" />
</ Headertemplate > < Itemtemplate >
< ASP: checkbox ID = "Rbtnname" Runat = "Server" CID = '<% # Eval ("candidatesid") % > '
Oncheckedchanged = "rbtnname_checkedchanged"/>
</ Itemtemplate >
</ ASP: templatefield >
</ Columns >
</ ASP: gridview >

 

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.