Select All buttons in gredview and delete them

Source: Internet
Author: User

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 );
}
}
}

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.