Hello all,
I am having a problem performing a calculation while in formview. I am using visual studio 2005, sql and C#. I have many textbox's that a user inputs, some of these require the calculation of subtotal and total. Here is a small example of what I have tried;
protected void Button1_Click1(object sender, EventArgs e)
{
//declare variables
decimal subtotal10:
decimal hour1010;
decimal hour1011;
decimal hour1020;
//get information from form
hour1010 = ((TextBox)FormView1.FindControl("Hours1010TextBox"));
hour1011 = ((TextBox)FormView1.FindControl("Hours1011TextBox"));
hour1020 = ((TextBox)FormView1.FindControl("Hours1020TextBox"));
//calculate hours
subtotal10 = hour1010 + hour1011 + hour1020 *1;
//display hours
TextBoa a = (TextBox)FormView1.FindControl("SubHours10TextBox");
a.Text = subtotal10;
FormView1.FindControl("TotalHoursTextBox").Focus();
}
All that I have tried decimal.parse, .Text, .ToString and I am getting error messages Can not cast string to int, int to string, decimal to int and all that fun stuff. The closest I have some in a concat in the subhours textBox.
What am I missing?? Any ideas??
Thanks