0

Hi,
I have two textboxes(which are diplay only;their values come from database).I need read the data from these textboxes,multiply them and display in the third text box.
Can someone send me the code.
For example consider textboxes names as txtprice,txtquantity,txtamount;

txtprice,txtquantity values come from tables in database.The price comes from Table COst and quantity comes from Table Inventory.
I want to diplay result in txtamount.

4
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by salmap
0
txtamount.Text = (Int32.Parse(txtprice.Text) * Int32.Parse(txtquantity.Text)).ToString(); // Integer values
txtAmount.Text = (Double.Parse(txtprice.Text) * Double.Parse(txtquantity.Text)).ToString(); // Real values
0

Thanks a lot.One more question.How to calculate the grand total?(Sum of all the amounts)

0

grand total of all values from database or grand total of these two textboxes?

int sum=0;
for(int i=0;i<yourvalues.Length-1;i++)
{
sum+=(Int32.Parse(yourvalues[i]));
}

Read values from database into string array yourvalues;

Edited by abelLazm: n/a

0
TextBox[] tbs = new TextBox[] { textBox1, textBox2 };
decimal total = 0M;
for(int i = 0; i < tbs.Lenght; i++)
     total += ConvertToDecimal(tbs[i].Text);
0

Sorry for my ignorance.But the 4th textbox is Txtbox4 should I replace Textbox[] with txtbox4[]?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.