Question : Error Message, CS0103: The name 'TextBox31' does not exist in the current context

I have a formview in a ASP.NET page.  I have a code that subtracts a value of "1" from a textbox and puts it in another.  I am using a submit button to complete the action however am getting a error of:

Compiler Error Message: CS0103: The name 'TextBox31' does not exist in the current context

Source Error:

 

Line 34:     protected void Button1_Click(object sender, EventArgs e)
Line 35:     {
Line 36:         TextBox31.Text = (int.Parse(TextBox30.Text) - 1).ToString();
Line 37:     }
Line 38: }
 
 
Please Help......

Answer : Error Message, CS0103: The name 'TextBox31' does not exist in the current context

You have to "find" every control you use in a formview, e.g.

protected void Button1_Click(object sender, EventArgs e)
{
         TextBox TextBox30 = (TextBox)myFormView.Row.FindControl("TextBox30");
         TextBox TextBox31 = (TextBox)myFormView.Row.FindControl("TextBox31");
         TextBox31.Text = (int.Parse(TextBox30.Text) - 1).ToString();
}

The pain of this alone is likely why I never used this silly control!
Random Solutions  
 
programming4us programming4us