网站后台管理之数据列表绑定、删除和修改(14)
发布时间:2021-06-07
发布时间:2021-06-07
}
protected void CheckBox2_CheckedChanged(object sender, EventArgs e) {
CheckAll(); }
选择好了要删除的行后,接下来要进行删除操作,双击删除选择项按钮进入单击事件,进行代码编写,具体代码如下:
<asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click" OnClientClick="return confirm('确认删除选择项?')">删除选择项</asp:LinkButton>
protected void LinkButton2_Click(object sender, EventArgs e) {
BLL.Article articleBll= new BLL.Article(); for (int i = 0; i < GridView1.Rows.Count; i++) {
CheckBox ck = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1"); HiddenField hdId = (HiddenField)GridView1.Rows[i].FindControl("HiddenFieldId");
if (ck.Checked == true) {
articleBll.Delete(Convert.ToInt32(hdId.Value)); } }
BindGridView();
Page.RegisterClientScriptBlock("", "<script>alert('批量删除成功');window.location.href='ArticleList.aspx'</script>");
}
上一篇:音频技术与应用发展趋势
下一篇:小学科学课外活动记录表