The checkbox uses the client control and adds the Ruanat=server property to the checkbox inside the Repeater
The properties of the Chktotal in the header must not be added to this property ....
Then select all of the JavaScript code
function Checkall ()
{
var e=document.aspnetform.elements;
var o;
for (Var i=0;i<e.length;i++)
{
o = e;
if (o.type== "checkbox" &o.id!= "Chktotal")
{
o.checked = document.getElementById ("Chktotal"). Checked;
} } }
Then decide if there is a selection, if there is no prompt!
function SelectOne ()
{
var e=document.aspnetform.elements;
var o;
var anyonechecked = false;
for (Var i=0;i<e.length;i++)
{
o = e;
if (o.type== "checkbox" & O.checked==true &o.id!= "Chktotal")
{
Anyonechecked = true;
Break
}
}
if (!anyonechecked)
{
Alert ("A project must be selected! ");
} }
Add a client control event to the deleted button
Delete event in background ... Note When binding the data, place the primary key (the unique index to be deleted as a hidden item in Reperter)
protected void Btndelete_click (object sender, EventArgs e)
{
for (int i = 0; i < RptMessList.Items.Count; i++)
{
if ((HtmlInputCheckBox) This.rptMessList.Items.FindControl ("Chkone"). Checked = = True)
{
int k = Ucar.Common.ConvertHelper.GetInteger ((RptMessList.Items.FindControl ("Hfid") as HiddenField). Value);
Bomessageds Bomessmodel = Bomessage.getmodel (k);
if (Bomessmodel! = null)
{
bomessmodel.ispublisheractive = 0;
Bomessage.update (Bomessmodel);
Ucar.Common.ScriptHelper.ShowAlertScript (this. Page, "Delete succeeded!" ");
}
}
}
The deletion behind me is the tombstone, the replacement state, we can directly delete can thank you to appreciate!
DataBind ();
}
<script language= "JavaScript">
<!--
function CA (frm)
{
var trk=0;
for (Var i=0;i<frm.elements.length;i++)
{
var e=frm.elements;
if (e.name! = ' Allbox ') && (e.type== 'checkbox') && (e.name! = ' do not want to be selectedcheckbox's name '))
{
trk++;
e.checked=frm.allbox.checked;
frm.del.disabled = frm.allbox.checked?false:true;//Select AllEffects on the disabled property of the Delete button
}
}
}
function CCA (FRM,CB)
{
var tb=to=0;
for (Var i=0;i<frm.elements.length;i++)
{
var e=frm.elements;
if (e.name! = ' Allbox ') && (e.type== 'checkbox') && (e.name! = ' do not want to be selectedcheckbox's name '))
{
tb++;
if (e.checked)
to++;
}
}
Frm.allbox.checked= (TO==TB) True:false;
if (0==to)//all unchecked and selected some effects on the disabled property of the Delete button
{
Frm.del.disabled = true;
}
Else
{
frm.del.disabled = false;
}
}
-
</script>
Call Method:
Select AllThe name is set to Allbox,onclickEvent execution CA (this.form);
Select the Checbox of the itemonclickEvent implementation CCA (This.form,this);
How to find a checkbox in repeater and implement a Select all delete