// Add an event to the checkbox on the DataGrid Column
Private void dg_list_itemcreated (Object sender, system. Web. UI. webcontrols. datagriditemeventargs E)
{
If (E. Item. itemtype = listitemtype. header)
{
Checkbox CBK = (checkbox) E. Item. findcontrol ("checkbox1 ");
CBK. checkedchanged + = new eventhandler (butall_click );
}
}
// Select all
Private void butall_click (Object sender, system. eventargs E)
{
System. Web. UI. webcontrols. checkbox;
If (butall. Text = "select all ")
{
Foreach (maid in dg_list.items)
{
Checkbox = (checkbox) datagriditem. findcontrol ("checkbox2 ");
Checkbox. Checked = true;
}
Butall. Text = "cancel ";
}
Else
{
Foreach (maid in dg_list.items)
{
Checkbox = (checkbox) datagriditem. findcontrol ("checkbox2 ");
Checkbox. Checked = false;
}
Butall. Text = "select all ";
}
}
// Set the zero button
Private void cancel_click (Object sender, system. eventargs E)
{
System. Web. UI. webcontrols. textbox text;
System. Web. UI. webcontrols. checkbox;
Foreach (maid in dg_list.items)
{
Checkbox = (checkbox) datagriditem. findcontrol ("checkbox2 ");
If (checkbox. Checked = true)
{
TEXT = (textbox) datagriditem. findcontrol ("textbox2 ");
Text. Text = "0 ";
}
}
}