示例#1
0
 /// <summary>
 /// 删除单条数据方法
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void lbtnDel_Click(object sender, CommandEventArgs e)
 {
     if (!string.IsNullOrEmpty(e.CommandName))
     {
         var res = _dataDal.DeleteList(e.CommandName);
         if (res)
         {
             //Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('删除成功!');</script>");
             BindData(true);
         }
         else
         {
             Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('删除失败!');</script>");
         }
     }
     else
     {
         Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('操作失败!');</script>");
     }
 }
示例#2
0
        /// <summary>
        /// 批量删除数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelAll_Click(object sender, EventArgs e)
        {
            string delStr = "";

            foreach (RepeaterItem item in rptListWork.Items)
            {
                CheckBox cb = (CheckBox)item.FindControl("cbList");
                if (cb == null || !cb.Checked)
                {
                    continue;
                }
                var litId = cb.ToolTip;
                if (litId != null)
                {
                    delStr += litId + ",";
                }
            }
            if (!string.IsNullOrEmpty(delStr))
            {
                delStr = delStr.Substring(0, delStr.Length - 1);
                var res = _dataDal.DeleteList(delStr);
                if (res)
                {
                    //Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('删除成功!');</script>");
                    BindData(true);
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('删除失败!');</script>");
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请选择您要操作的数据!');</script>");
            }
        }