<script type="text/javascript">
function SelectAll(tempControl)
{
//将除头模板中的其它所有的CheckBox取反
var theBox=tempControl;
xState=theBox.checked;
elem=theBox.form.elements;
for(i=0;i<elem.length;i++)
if(elem[i].type=="checkbox" && elem[i].id!=theBox.id)
{
if(elem[i].checked!=xState)
elem[i].click();
}
}
</script>
<asp:CheckBox ID="cbHeader" runat="server" Text="全选/反选" οnclick="javascript:SelectAll(this);"/>
-----------------------------------------------------
<asp:CheckBox ID="chkItem" runat="server"/>
<input id="hfID" runat="server" type="hidden" value='<%# Eval("ID")%>' />
foreach (RepeaterItem item in this.AnnounceList.Items)
{
CheckBox cb = (CheckBox)item.FindControl("chkItem");
if (cb.Checked == true)
{
int ID = Convert.ToInt32(((HtmlInputHidden)item.FindControl("hfID")).Value);
string strsql = "delete from Affiche where ID = " + ID + "";
try
{
conn = new OleDbConnection(connectionString);
conn.Open();
OleDbCommand comm = new OleDbCommand(strsql, conn);
comm.ExecuteNonQuery();
}
catch (System.Data.OleDb.OleDbException E)
{
throw new Exception(E.Message);
}
finally
{
conn.Close();
}
}
}
function SelectAll(tempControl)
{
//将除头模板中的其它所有的CheckBox取反
var theBox=tempControl;
xState=theBox.checked;
elem=theBox.form.elements;
for(i=0;i<elem.length;i++)
if(elem[i].type=="checkbox" && elem[i].id!=theBox.id)
{
if(elem[i].checked!=xState)
elem[i].click();
}
}
</script>
<asp:CheckBox ID="cbHeader" runat="server" Text="全选/反选" οnclick="javascript:SelectAll(this);"/>
-----------------------------------------------------
<asp:CheckBox ID="chkItem" runat="server"/>
<input id="hfID" runat="server" type="hidden" value='<%# Eval("ID")%>' />
foreach (RepeaterItem item in this.AnnounceList.Items)
{
CheckBox cb = (CheckBox)item.FindControl("chkItem");
if (cb.Checked == true)
{
int ID = Convert.ToInt32(((HtmlInputHidden)item.FindControl("hfID")).Value);
string strsql = "delete from Affiche where ID = " + ID + "";
try
{
conn = new OleDbConnection(connectionString);
conn.Open();
OleDbCommand comm = new OleDbCommand(strsql, conn);
comm.ExecuteNonQuery();
}
catch (System.Data.OleDb.OleDbException E)
{
throw new Exception(E.Message);
}
finally
{
conn.Close();
}
}
}