.aspx页面:
<script type="text/javascript">
function clickCheckbox(obj) {
$(".check").attr("checked", $(obj).attr("checked"));
}
</script>
<asp:Repeater ID="_rptMain" runat="server" onitemcommand="_rptMain_ItemCommand">
<ItemTemplate>
<input type="checkbox" id="ChkCheck" runat="server" class="check" value='<%#((IMDMSP.MODEL.B_Record_WebStructure)Container.DataItem).RecordID %>' />
</ItemTemplate>
</asp:Repeater>
<input type="checkbox" onclick="clickCheckbox(this);" />
<asp:LinkButton ID="_lbtnPassAll" runat="server" Text="批量通过" onclick="_lbtnPassAll_Click" ></asp:LinkButton>
.aspx.cs页面:
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
protected void _lbtnPassAll_Click(object sender, EventArgs e)
{
string ids = "";
foreach (RepeaterItem item in _rptMain.Items)
{
var checkbox = (HtmlInputCheckBox)item.FindControl("ChkCheck");
if(checkbox.Checked)
{
ids+=","+checkbox.Value;
}
}
if (ids.Length > 0)
{
var bRecordWebStructureManage = new IMDMSP.BLL.B_Record_WebStructureManage();
if (bRecordWebStructureManage.PassAll(ids.Substring(1)))
{
Response.Redirect(Request.Url.ToString());
}
}
}
sql语句:UPDATE B_Record_WebStructure SET CorfirmType='0' WHERE RecordID in (" + recordId + ")