0

hey everyone,

I'm just having a problem debugging this line and I don't see anything wrong with it. I tried using SelectValue and other ways but nothing seems to be working. The error message I get is that Exception Details: System.FormatException: Input string was not in a correct format.

if (check.PostalCodeChecking(DropDownList2.SelectedItem.Text, Convert.ToInt32(TextBox40.Text) ) == false)
    {
    Label2.Visible = true;
    }

The input in TextBox40 should be numeric..

Thanks in advance..

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by __avd
0

if you know for sure that textbox40.Text is a numeric value then it would probably help to post the code for check.PostalCodeChecking() to see what's going on inside that method. But you really should create an int variable and set it to the value of TextBox40 and then pass that variable into the method. It provides for better error checking. Also, do you really have 40 TextBoxes labeled as TextBox1, TextBox2, etc? If so you should really look into naming your controls with meaningful names, something that gives a hint of what the control is being used for. It makes debugging and maintaining your applications a lot simpler.

0

Thanks, pal. I don't have 40 text boxes. And, the problem was that I user another text box for post code..

0

Try this,

int num;
int.TryParse(TextBox40.Text,out num);

if(check.PostalCodeChecking(DropDownList2.SelectedItem.Text,num)==false)
  {
    Label2.Visible = true;
  }
This question has already been answered. 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.