I have the following code to do a some very simple validation for a textbox
if(txtInStock.Text.Length == 0)
txtInStock.Text = Convert.ToString(0);
if (txtInStock.Text.Length == 0)
txtOnOrder.Text = Convert.ToString(0);
int inStockAmt = Convert.ToInt32(txtInStock.Text);
int onOrderAmt = Convert.ToInt32(txtOnOrder.Text);
This works fine when Text != 0 , but when Text == 0 I get a FormatException saying the string is not of the proper format. How can I correct this?