akalmas
akalmas

Reputation: 329

adding up values of two textboxes and putting the computed value into the database

I am creating an application which has 3 text boxes, the user inputs two integer values and then 3rd text box is a readonly box and is meant to contain the sum of the two input values. all these input values are then supposed to be adding to their corresponding fields int he database table. Can some one help show me the code that can implement this?

Upvotes: 0

Views: 711

Answers (1)

jdoig
jdoig

Reputation: 1492

As Marc said, your question is very vague, maybe you need something like:

        int a, b, c;
        if (int.TryParse(textBox1.Text, out a) && int.TryParse(textBox2.Text, out b))
        {
            c = a + b;
            textBox3.Text = c.ToString();
            myNumberRepository.Add(c); //Assuming you already have a way to write to the DB;
        }

Assuming your accessing the UI elements directly by name. If your binding to values in the code behind or a viewmodel replace textBoxX.Text with those values.

Upvotes: 1

Related Questions