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..

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.

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

Try this,

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

if(check.PostalCodeChecking(DropDownList2.SelectedItem.Text,num)==false)
  {
    Label2.Visible = true;
  }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.