后台数据管理

来源:互联网 发布:网络教育本科怎么报名 编辑:程序博客网 时间:2024/06/05 09:20
        #region 全选
        protected void cbAll_CheckedChanged(object sender, EventArgs e)
        {
            foreach (RepeaterItem item in rptList.Items)
            {
                CheckBox cb = item.FindControl("cbItems") as CheckBox;
                cb.Checked = cbAll.Checked;
            }
        } 
        #endregion


        #region 删除
        protected void btnDel_Click(object sender, EventArgs e)
        {
            string ids = "";
            foreach (RepeaterItem item in rptList.Items)
            {
                CheckBox cb = item.FindControl("cbItems") as CheckBox;
                if (cb.Checked) 
                {
                    ids = ids + cb.ToolTip + ",";
                }
            }
            ids = ids.TrimEnd(',');
            if (string.IsNullOrWhiteSpace(ids))
            {
                HtmlCommon.ShowMsg("请选择您要删除的数据");
                return;
            }
            else 
            {
                string[] strArry = ids.Split(',');
                BLL.QuestionBLL Bll = new BLL.QuestionBLL();
                int result = Bll.DeleteByIDs(strArry);
                if (result > 0)
                {
                    HtmlCommon.ShowMsg("删除成功!", "dept.aspx");
                }
                else 
                {
                    HtmlCommon.ShowMsg("删除失败!");
                }
            }


        } 
        #endregion
0 0
原创粉丝点击