I have three textboxes(textbox1,textbox2,textbox4). Am trying to calculate the percentage of textbox1.value to textbox3.value. Want to display the percentage in texbox4 on the fly. Is there an easy way to do this? it currently tells me the input string is not in correct format. Have tried numerous things. Any direction would be greatly appreciated. See code below.
Jason
Jason
SqlConnection connSomsys = new SqlConnection(@"Server=cmdivst004\Jason08;Integrated Security=false;Database=QuoteDB; Persist Security Info=True;User ID=cmdiapp;Password=adiadmin"); |
SqlCommand selectCommand; |
selectCommand = new SqlCommand("sprocgetQuoteProductTotals", connSomsys); |
selectCommand.CommandType = CommandType.StoredProcedure; |
SqlDataAdapter adapter = new SqlDataAdapter(selectCommand); |
DataSet dataSet = new DataSet(); |
adapter.Fill(dataSet); |
this.DataSource = dataSet; |
this.DataMember = "Table"; |
this.textBox3.Value = dataSet.Tables[1].Rows[0][0].ToString(); |
int textbox1val; |
int textbox3val; |
textbox1val = Convert.ToInt32(this.textBox1.Value); |
textbox3val = Convert.ToInt32(this.textBox3.Value); |
decimal percent = (textbox1val * 100) / textbox3val; |
string textbox4val = Convert.ToString(percent); |
this.textBox4.Value = textbox4val; |