.NET经验心得探讨社区  
请在这里用键盘敲打出属于你的地位!

  private void dg_DSC_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
  {
   string id=e.Item.Cells[1].Text;
   string sql="delete CSD_PROMOTE_MAIN where PROMOTE_ID='"+id+"'";
   try
   {
    DbManage.ExecuteNonQuery(sql);
    int index=this.dg_DSC.CurrentPageIndex;
    if((this.dg_DSC.PageCount-this.dg_DSC.CurrentPageIndex)==1 && this.dg_DSC.Items.Count==1)
    {
     if(this.dg_DSC.PageCount>1)
     {
      index=index-1;
     }
     else
     {
      index=0;
     }
    }
    this.dg_DSC.CurrentPageIndex=index;
    Response.Write("<script>alert('删除数据成功!');</script>");
    dgBind();
   }
   catch
   {
    Response.Write("<script>alert('删除数据失败!请重试!');</script>");
   }

  }

posted on 2006-02-11 18:21  苦涩的咖啡  阅读(327)  评论(0编辑  收藏  举报