check box select all, bulk delete

Source: Internet
Author: User

Script Select All

1"Server">2<title></title>3<script type="Text/javascript">4 function SelectAll (chk) {5             varCheckboxs = document.getElementsByTagName ("input");6              for(vari =0; i < checkboxs.length; i++) {7                 if(Checkboxs[i].type = ="checkbox"){8Checkboxs[i].checked= Chk.checked;9                 }Ten             } One         } A</script> -

1<HeaderTemplate>2<asp:checkbox id="Cboselectall"text="Select All"runat="Server"autopostback="True"Oncheckedchanged="cboselectall_checkedchanged"/>|4<input type="checkbox"Id="Htmlcboselectall"onclick="SelectAll (This)"/>JS Select all<br/>6<asp:linkbutton id="lbdeleteselected"runat="Server" 7onclick="Lbdeleteselected_click"onclientclick="return confirm (' Are you sure you want to delete it in bulk? ')"> Bulk Delete </asp:LinkButton>8</HeaderTemplate>
1  //Bulk Delete2         protected voidLbdeleteselected_click (Objectsender, EventArgs e)3         {4             BOOLHasdeleterow =false;//Is there a check for the item you want to delete5StringBuilder Bookids =NewStringBuilder ("Delete from BookInfo where BookID in (");6             //traverse rows in the GridView to get the primary key value of the selected row7             foreach(GridViewRow rowinch  This. Gvbookinfos.rows)8             {9                 if((CheckBox) row. FindControl ("Cboselect")). Checked)Ten                 { OneHasdeleterow =true; A                     intBookID = Convert.ToInt32 ( This. Gvbookinfos.datakeys[row. RowIndex]. Value); -Bookids.append (bookid+","); -                 } the             } -             //If no row is selected, give the appropriate prompt -             if(!Hasdeleterow) -             { +Page.ClientScript.RegisterStartupScript ( This. GetType (),"","alert (' Please select the option to delete! ')",true); -                 return; +             } A             stringids =bookids.tostring (); atids = IDs. Substring (0Ids. length-1)+")"; -             intresult =Dbutil.executesql (IDS); -             if(Result >0) -             { -Page.ClientScript.RegisterStartupScript ( This. GetType (),"","alert (' Bulk Delete succeeded! ')",true); - Gridviewbind (); in             } -             Else to             { +Page.ClientScript.RegisterStartupScript ( This. GetType (),"","alert (' Bulk delete failed! ')",true); -             } the}

check box select all, bulk delete

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.