954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ASP Error

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

rotten69
Posting Whiz
346 posts since May 2011
Reputation Points: 3
Solved Threads: 16
 

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.

Cherryhomesj
Junior Poster in Training
58 posts since Sep 2011
Reputation Points: 30
Solved Threads: 17
 

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

rotten69
Posting Whiz
346 posts since May 2011
Reputation Points: 3
Solved Threads: 16
 

Try this,

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

if(check.PostalCodeChecking(DropDownList2.SelectedItem.Text,num)==false)
  {
    Label2.Visible = true;
  }
__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You