Exemple #1
0
        protected void DataList1_DeleteCommand(object sender, DataListCommandEventArgs e)
        {
            WorkdtArticleBLL workdtarticlebll2 = new WorkdtArticleBLL();
            string           id = e.CommandArgument.ToString();

            //string url1 = ((System.Web.UI.WebControls.Image)e.Item.FindControl("CommodityImage")).ImageUrl.ToString();
            //if (url1 != null && url1 != "") {
            //    string webFilePath = Server.MapPath(url1);//用来删除原有的图片
            //    System.IO.FileInfo file = new System.IO.FileInfo(webFilePath);
            //    if (file.Exists)
            //    {
            //        file.Delete();//删除
            //    }
            //    string url3 = ((System.Web.UI.WebControls.Image)e.Item.FindControl("basicImage")).ImageUrl.ToString();
            //    string webFilePath2 = Server.MapPath(url3);//用来删除原有的图片
            //    System.IO.FileInfo file2 = new System.IO.FileInfo(webFilePath2);
            //    if (file2.Exists)
            //    {
            //        file2.Delete();//删除
            //    }
            //}
            if (workdtarticlebll2.Delete(id))
            {
                Response.Write("<script>alert('删除成功');</script>");
            }
            this.Response.Redirect(this.Request.Url.ToString());
        }
Exemple #2
0
 protected void Delete_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < DataList1.Items.Count; i++)
     {
         if (((CheckBox)DataList1.Items[i].FindControl("selected")).Checked == true)
         {
             object           s = ((System.Web.UI.WebControls.HyperLink)DataList1.Items[i].FindControl("Hyperlink3")).Text;
             WorkdtArticleBLL workdtarticlebll = new WorkdtArticleBLL();
             if (workdtarticlebll.Delete(s))
             {
                 Response.Write("<script>alert('删除成功');</script>");
             }
         }
     }
     this.Response.Redirect(this.Request.Url.ToString());
 }