全选 全消 多条记录删除(asp.net)
<asp:CheckBox id="chkExport" runat="server" ></asp:CheckBox>
<INPUT id="Hidden1" type="hidden" size="1" name="Hidden1" runat="server" value='<%# DataBinder.Eval(Container.DataItem,"id")%>'>
System.Web.UI.WebControls.CheckBox chkExport;
if(cmdSelectAll.Text == "全选")
{
foreach(RepeaterItem item in Repeater1.Items)
{
chkExport = (CheckBox)item.FindControl("chkExport");
chkExport.Checked =true;
}
cmdSelectAll.Text = "全消";
}
else
{
foreach(RepeaterItem item in Repeater1.Items)
{
chkExport = (CheckBox)item.FindControl("chkExport");
chkExport.Checked = false;
}
cmdSelectAll.Text = "全选";
}
System.Web.UI.WebControls.CheckBox chkExport;
string sID;
foreach (RepeaterItem item in Repeater1.Items)
{
chkExport = (CheckBox)item.FindControl("chkExport");
//如果选中了则取值
if(chkExport.Checked)
{
sID=((HtmlInputHidden)item.FindControl("Hidden1")).Value.ToString();
Response.Write(sID);
}
}