Edit the template-> the header template and the item template each have a checkbox. Change the name in the header template, for example, all. Do not worry about the other.
<SCRIPT type = "text/JavaScript" Language = "JavaScript"> // script implementation
Function getall (chkselectall)
{
VaR item = Document. getelementsbytagname ("input ");
For (I = 0; I <item. length; I ++)
{
If (item [I]. type = "checkbox ")
{
Item [I]. Checked = chkselectall. checked;
}
}
}
</SCRIPT>
<Asp: checkbox id = "chkselectall" runat = "server" text = "select all" onclick = "getall (this)" // when calling
// Perform operations on data rows. For example, the confirmation box is displayed when you delete the data rows.
Protected void gdvaccounts_rowdatabound (Object sender, gridviewroweventargs E)
{
If (E. Row. rowtype = datacontrolrowtype. datarow)
{
E. Row. Attributes. Add ("onmouseover", "c = This. style. backgroundcolor; this. style. backgroundcolor = '# 6699ff '");
E. Row. Attributes. Add ("onmouseout", "This. style. backgroundcolor = C ");
// (Linkbutton) (E. row. cells [6]. controls [0]). attributes. add ("onclick", "Return confirm ('Are you sure you want to delete it? ')");
}
}
// Click Delete to delete the Row Records selected by the check box.
Protected void button#click (Object sender, eventargs E)
{
Foreach (gridviewrow item in gdvaccounts. Rows)
{
If (checkbox) (item. findcontrol ("checkbox1"). Checked)
{
String id = item. cells [0]. text;
Bll. deleteaccounts (ID );
Bll. bindaccounts (gdvaccounts );
}
}
}