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