When i Press the Submit button after filling the form the form is refresh but data is not submitted in the Database and i am trying to store data using the stored procedure. Thanks

[Button Code]

 <div class="col-xs-12 col-sm-12 text-center">
     <asp:Button ID="Submit_Button" class="btn btn-info btn-md" runat="server" onClickButton="Submit_Form_Click" Text="Submit" />
 </div>

[ASP.NET Code Behind]

 protected void Submit_Form_Click(object sender, EventArgs e)
 {
      string Sponsirship_TypeValue = Sponsirship_Type.SelectedValue;
      string Select_Gender = Gender.SelectedValue;
      string Marital_Status = MaritalStatus.SelectedValue;
      string connStr = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
      SqlConnection con = new SqlConnection(connStr);
      con.Open();
      SqlCommand cmd = new SqlCommand("sp_Student_Registration", con);
      cmd.CommandType = CommandType.StoredProcedure;
      SqlParameter paramReg_Num = new SqlParameter("@PHD_Registration_Number", Session["LoginUserName"]);
      SqlParameter paramSponsirship_Type = new SqlParameter("@SponsershipType", Sponsirship_TypeValue);
      cmd.ExecuteNonQuery();

      int result = cmd.ExecuteNonQuery();

      Response.Write("Number of Changes" + result);
 }

1 Answers

1
vladimirG On

Replace onClickButton with OnClick:

Example:

<asp:Button id="Button1"
           Text="Submit"
           OnClick="SubmitBtn_Click" 
           runat="server"/>