Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8489729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:54:33+00:00 2026-06-10T21:54:33+00:00

I have two textboxes and two submit buttons. Each button submits the information in

  • 0

I have two textboxes and two submit buttons. Each button submits the information in the textbox, I would like to have 1 submit button that submits both texboxes at once without. The problem is, if one textbox is empty then it overwrites the data with empty data. I would like it only to submit information if there’s something in the textbox. Some pseudocode code might help:

  • if textbox1 is empty then do nothing, if textbox2 has data then update database.
  • if textbox1 has data then update if textbox2 is empty then do not update textbox2.

Here is my code, I hope what i’m saying makes sense.

protected void Button3_Click(object sender, EventArgs e)
    {

            SqlConnection conns = new SqlConnection(ConfigurationManager.ConnectionStrings["TestDBConnectionString1"].ConnectionString);
            SqlCommand cmd = new SqlCommand("UPDATE test SET SitUps = @SitUps WHERE (Id = @Id)", conns);
            cmd.CommandType = CommandType.Text;
            Label IdL = ((Label)FormView1.FindControl("IdLabel"));
            cmd.Parameters.AddWithValue("@Id", IdL.Text);
            cmd.Parameters.AddWithValue("@SitUps", Sits.Text);
            conns.Open();
            cmd.ExecuteNonQuery();
            Label17.Text = "Successfully Submitted Sit-Ups!";

    }

    protected void Button4_Click(object sender, EventArgs e)
    {

            SqlConnection conns = new SqlConnection(ConfigurationManager.ConnectionStrings["TestDBConnectionString1"].ConnectionString);
            SqlCommand cmd = new SqlCommand("UPDATE test SET pushUps = @pushUps WHERE (Id = @Id)", conns);
            cmd.CommandType = CommandType.Text;
            Label IdL = ((Label)FormView1.FindControl("IdLabel"));
            cmd.Parameters.AddWithValue("@Id", IdL.Text);
            cmd.Parameters.AddWithValue("@pushUps", Push.Text);
            conns.Open();
            cmd.ExecuteNonQuery();
            Label18.Text = "Successfully Submitted Push-Ups!";

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:54:34+00:00Added an answer on June 10, 2026 at 9:54 pm

    Looks like you just need to add if(Push.Text!=””) and if(Sits.Text!=””) before each of the blocks you trying to run

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with two text boxes and two buttons (one submit button,
I have a web page that contains two textboxes and a button. I can't
I have a form with two textboxes and a submit button. The second box
I am working on an mvc application. Two tables each have their individual submit
I have two different input fields with their own respective submit buttons and I
I have created a custom validator (below) that checks two textboxes to make sure
I have a Table with two textboxes. Every textbox has a required validator to
I have two buttons inside a form call: <% using (Html.BeginForm()) {%> <input type=submit
I have a form which has a few text boxes, and two submit buttons.
I have a page for modification of customer information, I allow two textboxes on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.