NeoVe
NeoVe

Reputation: 3897

How to clear inserted data into db from button

I have this reference to a method (Botones) in my codebehind file:

public partial class EnvianosTuCurriculum : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        Botones botones = new Botones();
        botones.SaveCVInfo2(nombre.Text, Apellidos.Text, EmpleoS.Text, DireccionPersonal.Text, RadioButtonList6.SelectedItem.Text, contraseña.Text, TelHabi.Text, TelCel.Text, userEmail.Text, Nacionalidad.Text, LugarNaci.Text, FechaNac.Text, Edad.Text, Cedula.Text, EsCivil.Text, ProUofi.Text, Estatura.Text, Peso.Text, TipoSang.Text, RadioButtonList7.SelectedItem.Text, Lateralidad.Text, LicCond.Text, RadioButtonList5.SelectedItem.Text, MaMoVeh.Text, RadioButtonList4.SelectedItem.Text, EmpCta.Text, ProMens.Text, SuelAs.Text, RadioButtonList3.SelectedItem.Text, NomRec.Text, RadioButtonList2.SelectedItem.Text,Insti.Text, horario.Text, vivequien.Text, RadioButtonList1.SelectedItem.Text, otresp.Text, Ciudad.Text);
        Response.Redirect("Envia2.aspx");
    }

}

Now, if I add another button Button2 I need to go back to previous page, and also clear all data sent to Database from these controls.

I guess i need an if statement there, but i just can add a Response.Redirect("previous_page.aspx"), don't know how to actually clear the data into db.

With Response.Redirect i can just go back and all fields look empty, but i will start filling them again, as a new user, i need to not only go back, but also undo all the data inserted into the db table.

How can i achieve this?

Upvotes: 0

Views: 106

Answers (1)

Computer
Computer

Reputation: 2227

Personally i would first add Validators and any other relevant controls to ensure that the data entered is what it should be and/or store the data temporarily before committing it to the database (which would avoid deleting it).

However if this is not applicable to delete data in SQL you would have something along the lines of

DELETE FROM table_name
WHERE some_column=some_value

Have a look at this link for further info/understanding http://www.w3schools.com/sql/sql_delete.asp

Upvotes: 1

Related Questions