<SCRIPT type = "text/JavaScript">
// Set the selected status of all checkboxes Based on the selected status of the input checkbox
Function selectall (OBJ)
{
VaR allinput = Document. getelementsbytagname ("input ");
// Alert (allinput. Length );
VaR looptime = allinput. length;
For (I = 0; I <looptime; I ++)
{
// Alert (allinput [I]. type );
If (allinput [I]. type = "checkbox ")
{
Allinput [I]. Checked = obj. checked;
}
}
}
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Table Style = "width: 497px; Height: 363px">
<Tr>
<TD rowspan = "3" style = "width: 100px">
<Uc1: carte id = "carte1" runat = "server"/>
</TD>
<TD colspan = "2" rowspan = "3">
<Asp: gridview id = "gridview1" runat = "server" allowpaging = "true" autogeneratecolumns = "false"
Datakeynames = "productid" datasourceid = "sqldatasource1">
<Columns>
<Asp: templatefield>
<Itemtemplate>
<Asp: checkbox id = "chk_del" runat = "server"/>
</Itemtemplate>
</ASP: templatefield>
<Asp: boundfield datafield = "productid" headertext = "no." insertvisible = "false"
Readonly = "true" sortexpression = "productid"/>
<Asp: boundfield datafield = "client" headertext = "customer" sortexpression = "client"/>
<Asp: boundfield datafield = "item" headertext = "project" sortexpression = "item"/>
<Asp: boundfield datafield = "addmine" headertext = "time" sortexpression = "addmine"/>
<Asp: commandfield headertext = "operation" showdeletebutton = "true"/>
<Asp: templatefield headertext = "operation">
<Itemtemplate>
<A href = 'P _ app. aspx? Id = <% # eval ("productid") %> '0> edit </a>
</Itemtemplate>
</ASP: templatefield>
</Columns>
</ASP: gridview>
<Asp: checkbox id = "chk_js" runat = "server" text = "select all" onclick = "selectall (this)"/>
<Asp: button id = "btn_deleterecords" runat = "server" onclientclick = "Return judgeselect ();" text = "delete" onclick = "btn_deleterecords_click"/>
I also use JS
// JScript File
// Determine whether to select a record and confirm deletion
Function judgeselect ()
{
VaR result = false;
VaR allinput = Document. getelementsbytagname ("input ");
VaR looptime = allinput. length;
For (I = 0; I <looptime; I ++)
{
If (allinput [I]. Checked)
{
Result = true;
Break;
}
}
If (! Result)
{
Alert ("select the record to be deleted first! ");
Return result;
}
Result = confirm ("are you sure you want to delete the selected record? ");
Return result;
}
But it cannot be deleted,
Is it necessary to write back-end?Code?
Am I writing this?
Thank you!