protected void BtnSave_Click(object sender, EventArgs e) { lblUserName.Text = Session["LoginName"].ToString(); { string connetionString = "Data Source=ANONYMOUS-PC\\SQLEXPRESS;Initial Catalog=EmployeeDB;User ID=sa;Password=Mo7am00d"; using (SqlConnection con = new SqlConnection(connetionString)) { using (SqlCommand cmd = new SqlCommand("SP_DELMASTER", con)) { objLogin.Delnum = TxtDelNum.Text; DataTable dtTrans = new DataTable(); dtTrans = objLogin.ValidateDel(); if (dtTrans.Rows.Count != 0) { Response.Redirect("ErrorDel.aspx"); } else { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Mode", SqlDbType.VarChar).Value = "Insert"; cmd.Parameters.Add("@LOCID", SqlDbType.VarChar).Value = ddlLocation.SelectedValue.ToString(); cmd.Parameters.Add("@DELNO", SqlDbType.VarChar).Value = TxtDelNum.Text.ToString(); cmd.Parameters.Add("@DELDESC", SqlDbType.VarChar).Value = txtDelDesc.Text.ToString(); cmd.Parameters.Add("@USERNAME", SqlDbType.VarChar).Value = lblUserName.Text.ToString(); con.Open(); cmd.ExecuteNonQuery(); } } } } BindGridview(); }