(1). Functions
1. Retrieve the checkbox in JavaScript and enable full selection and elimination.
The checkbox written in C # must be sent back to the server for execution,
Javascript can be implemented directly on the client, which is more efficient.
(2 ).Code
1. Main code snippets in the DataGrid:
<Columns>
<Headertemplate> // header template code
<Asp: checkbox id = chkheader runat = server autopostback = false // set autopostback to false and do not need to be resend
Onclick = javascript: selectall (this);> </ASP: checkbox>
</Headertemplate>
<Itemtemplate> // item template code
<Asp: checkbox id = chkitem runat = Server> </ASP: checkbox>
</Itemtemplate>
</Columns>
2. Add:
<Script language = JavaScript>
Function selectall (tempcontrol)
{
// Retrieve all other checkboxes except the header Template
VaR thebox = tempcontrol;
Xstate = thebox. checked;
ELEM = thebox. form. elements;
for (I = 0; I If (ELEM [I]. type = checkbox & ELEM [I]. ID! = Thebox. ID)
{< br> If (ELEM [I]. Checked! = Xstate)
ELEM [I]. Click ();
}< BR >}< br>