Pages

Thursday, 2 February 2012

Delete The Record from the Grid View

 protected void deletebtn_Click(object sender, ImageClickEventArgs e)
    {
        if (Session["TitleService"].ToString() == "Events" || Session["TitleService"].ToString() == "Brand Promotions" || Session["TitleService"].ToString() == "Merchandising Services" || Session["TitleService"].ToString() == "Road Shows")
        {
            lbldelete.Text = "Service Can Not Be Deleted";
        }
        else
        {
            SqlCommand cmd = new SqlCommand("DeleteService", con);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter p1;
            p1 = new SqlParameter("@pSno", SqlDbType.Int);
            p1.Value = Convert.ToInt32(Session["Sno"].ToString());
            cmd.Parameters.Add(p1);
            con.Open();
            cmd.ExecuteNonQuery();
            GetServiceName();
            con.Close();
            lblstatus.Text = "<script>" + Environment.NewLine + "alert('Advertisment Deleted Successfully')</script>";
            panel2.Visible = true;
        }
    }

No comments:

Post a Comment