Devexpress aspxgridview get the IDs to be deleted or changed in batches (select all the aspxgridview check boxes | invert Selection Function

Source: Internet
Author: User

Step 1: display the checkbox button;

Click columns in aspxgridview. You can directly add a command column line or select one option and then click Change to commadn column. The default showselectcheckbox is true, so we don't need to worry about it, in this way, you can see that each row has a checkbox button.

Step 2: check box is displayed in the table header and click "Select All". | select inverse;

Switch backSource code, Locate the gridviewcommandcolumn of aspxgridview, and add





Add a Dev checkbox button in headertemplate and set its style to horizontalalign = "center, we added a function (s, e) {dgvwemail to the checkbox button clientsideevents-checkedchanged. selectallrowsonpage (S. getchecked () ;}, dgvwemail is the ID of your aspxgridview control. At this point, you can select all the table headers | invert selection is enabled;

Step 3: Obtain the ID of the selected row for batch deletion or modification;

Add a Dev button to the page and add a click event to the button;

First, we write a method to obtain the IDs of all selected rows.

Protected string getdelid () {string delid = "";

// Obtain the selected record ID list <Object> lselectvalues = dgvwemail. getselectedfieldvalues ("ID ");

For (INT I = 0; I <lselectvalues. Count; I ++) {delid + = lselectvalues [I] + ",";}

Delid = delid. substring (0, delid. lastindexof (','));

Return delid ;}

 

This method obtains the ID of the selected row, obtains the id Primary Key of the bound data through aspxgridview. getselectedfieldvalues ("ID"), and then traverses the obtained ID;

The next step is the same as writing all the other options for deletion. You can try to write them.

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.